Re: [PATCH 5/4] run-command: implement abort_async for pthreads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 01, 2011 at 07:27:03PM +0200, Johannes Sixt wrote:

> > OK, I've read up on thread-cancellation, and this code seems correct.
> > pthread_cancel doesn't kill the thread right away, it just signals a
> > cancellation-event, which is checked for at certain
> > cancellation-points. A lot of the CRT functions are defined as
> > cancellation points, so it'll be a matter for us Win32-guys to
> > implement pthread_testcancel() and inject that into the
> > function-wrappers of the CRT functions that are marked as
> > cancellation-points.
> 
> That's not going to happen. We cannot implement pthread_cancel() on Windows 
> because it would have to be able to interrupt blocking system calls. 
> (TerminateThread() is a no-no, given all the caveats about leaking system 
> resources that are mentioned in the manual.)
> 
> [OK, "cannot" is a hard word. It is possible in some way, I'm sure. But that 
> would mean that we implement the equivalent of Cygwin or so...]
> 
> But if I understand correctly what Jeff wrote so far, then the pthreaded case 
> happens to work - by chance or by design, we don't know (yet). Perhaps we can 
> get away with
> 
> -	/* no clue */
> +	/* pthread_cancel(async->tid); not necessary */

Yeah, I think that would probably work, but I haven't had a chance yet
to look deeper into why the pthread case doesn't hang.

I have another case, too, which is that killing a "git push" in progress
via signal will leave crufty child-processes around, still trying to
push.  One of these is the pack-objects sub-process, and the other is
(in the no-pthreads case) the sideband demuxer.

And obviously fixing that involves aborting the async process, too[1].
But we can again get away without pthread_cancel, because in the pthread
case, we can just rely on the parent process dying to take down the
thread.

-Peff

[1] Actually, my plan is to set up a signal/atexit handler to kill off
children.  Run-command callers can specify an option for "yes, this
child should be killed if I am killed". Async callers will have it
turned on automatically (since they won't even know if it's a subthread
or a different process).  So we won't actually be calling abort_async()
anyway.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]