gnustep-dev
[Top][All Lists]
Advanced

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

Re: why does NSTask setpgrp on sub processes?


From: Richard Frith-Macdonald
Subject: Re: why does NSTask setpgrp on sub processes?
Date: Wed, 20 Jan 2010 11:36:49 +0000

On 20 Jan 2010, at 09:48, Derek Zhou wrote:

> Oops, hit send too soon.
> 
> #import <Foundation/Foundation.h>
> 
> int main(int argc, char** argv)
> {
>  NSTask* editor = [NSTask new];
>  [editor setLaunchPath: @"vi"];
>  [editor launch];
>  [editor waitUntilExit];
>  NSLog(@"finished\n");
> }
> 
> with the setpgrp (current behavior) it will hang because vi cannot get hold 
> of the tty. 
> without the patch which basically disable setpgrp vi will show and after you 
> close vi
> this program will exit.
> I can add tcsetpgrp after the launch so vi can get hold of the tty but then 
> after vi 
> exit tty control is not back to my prog but the shell. I have to fg or send 
> SIGCONT
> to continue my prog.
> I see what you mean, currently it is trying to send signal to the new group. 
> But how many cases you really want to do that instead of just sending to the 
> single 
> process? Also by default if parent got killed all children got killed 
> (SIGHUP? I 
> am not sure) so the behavior is still roughly unchanged.     

After looking at and trying out the above program, it seems there was a 
problem, but your diagnosis was wrong.

The issue was not that NSTask changes the process group (which it should), but 
rather that it was failing to detach the process from the controlling terminal 
(except when using pseudo-terminals).  I have copied the code used with pseudo 
terminals so that it's always used.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]