penneyj@servio.UUCP (D. Jason Penney) (05/16/89)
I've found my problem! The answer is interesting enough that I'm posting this follow-up, as I threatened I would. To recap the problem description: In a fork()'d and execve()'d task, stderr was not getting printed, and in fact programs were trashing their address space in an odd way. This ONLY happened under csh -- Bourne shell worked properly. Here is what I did wrong: before doing the execve() I closed stdin so that the forked process would not share stdin with the parent process: close(0); What csh is evidently doing is closing stderr and then re-opening it, thus leaving descriptor 2 uninitialized. Thus, if you want to bit-bucket stdin in a forked process, the correct approach is, close(0); open("/dev/null", O_RDONLY); so that csh will get file descriptor 2 when it reopens stderr. Many thanks to Maarten Litmaath @ VU Amsterdam, who encouraged me to keep looking until I found the problem. -- D. Jason Penney Ph: (503) 629-8383 Beaverton, OR 97006 uucp: ...ogccse!servio!penneyj STANDARD DISCLAIMER: Should I or my opinions be caught or killed, the company will disavow any knowledge of my actions...