Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fork, pipes, and Tiger



On Thu, Dec 22, 2005 at 11:22:45PM +0100, Martin Costabel wrote:
> I am trying to understand why TeXmacs' shell plugin doesn't work on 
> Tiger. This plugin is a simple binary executable compiled from the C++ 
> code I am attaching below. It is supposed to run /bin/sh as a child and 
> run its stdin/out through the calling process. This works on OSX 10.3, 
> but not on 10.4. What has changed on Tiger with respect to fork/pipes?
> 
> If you compile the attached file tm_shell.cpp simply with
> 
>   g++ -o tm_shell tm_shell.cpp
> 
> and then run ./tm_shell from the command line, it should just look like 
> a new shell with a different prompt. This is also what happens on 
> Panther. On Tiger, what happens is
> 
> % ./tm_shell
> verbatim:Shell session inside TeXmacsverbatim:
> [1]  + 21241 Suspended (tty input)     ./tm_shell
> 
> If I fg the process, it suspends itself immediately again. This is also 
> what happens when one tries to run the shell plugin from within TeXmacs; 
> the whole TeXmacs process gets suspended and has to be forcibly killed.
> 
> It doesn't matter where the binary is compiled, on Panther or on Tiger, 
> or with which version of g++. If the identical binary is run on Panther, 
> it works; if it is run on Tiger, it doesn't.
> 
> Does anyone see what is wrong with the code or why it wouldn't work on 
> Tiger?

The bash in Tiger seems to stay in a loop ioctl'ing STDERR (duped to fd
255) and killing -21 (SIGTTIN) the processes it its group (including the
parent).

And killing the main process makes sh consume all cpu.

Using socketpair instead of two pipes makes it work.

Even with shell_output = for (;;); the main process still receives
SIGTTIN, so I guess it's a bug in bash.

-- 
lfr
0/0
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/unix-porting/email@hidden

This email sent to email@hidden

References: 
 >fork, pipes, and Tiger (From: Martin Costabel <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.