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



I may be able to contribute some data points to the discussion -
I put together an application which does the following:
1) Uses NSTask to set up a process
2) defines 3 pipes for stdin, stdout, and stderr to communicate to the process
3) sets up the desired parms and selects "/bin/bash" as the program path.
4) launches bash.
5) everything works beautifully
a) commands typed in are picked up by bash from the stdin pipe
b) bash output goes back to the application on the stdout pipe
c) if I, for example, type an invalid command, the error message comes back properly on the stderr pipe.
d) however, I get no Prompt.
6) If I change the bash parms to include the -i flag:
a) Nothing comes back on stdout or stderr
b) The bash process is in a hard loop (near 100% processor activity)
c) It has to be killed with "force quit"
7) If I chage the stderr assignment to a disk file, the prompts and errors go to the disk file as expected.
8) If I remove the stderr assignment, and run the application from XCODE, the prompts and error message show up
in the run log window.
Since it works properly without the "-i" flag, I believe there is either a bash problem, or there is something really
subtle I missed which allows the pipe to work properly without the "- i" flag. I suggest as a possibility that maybe bash
expects a terminal to to be assigned to stderr unless it is assigned to a disk file, and doesn't check for a pipe.
If I've said anything stupid here, I offer the excuse that I'm really a mainframe dinosaur and haven't yet absorbed
enough UNIX to be dangerous.


Dale Miller
email@hidden



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

This email sent to 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.