Path: utzoo!attcan!uunet!tektronix!psueea!parsely!bucket!servio!penneyj From: penneyj@servio.UUCP (D. Jason Penney) Newsgroups: comp.unix.questions Subject: csh Rerouting stderr Summary: Where Does it Put stderr? Message-ID: <122@servio.UUCP> Date: 10 May 89 17:56:49 GMT Reply-To: penneyj@servio.UUCP (D. Jason Penney) Organization: Servio Logic Development Corp.; Beaverton, OR Lines: 57 I have a question that some one with Unix source should be able to easily answer for me. THE ENVIRONMENT: SunOS (or AIX) Unix. THE SCENARIO: my program is fork()'ing another process which eventually execve()'s a shell script. Before the execve(), the program reroutes stdout and stderr to a disk file: fork(); ... setpgrp(0, getpid()); close(1); /* stdout */ close(2); /* stderr */ dup(creat("logfile", 0644); /* points 1 and 2 at logfile */ ... execve("script", argv, envp); THE PROBLEM: If script is as follows, #! /bin/sh frob logfile contains frob: not found (Other more sophisticated tests show that stderr is indeed being rerouted properly.) If script is as follows, #! /bin/csh frob nothing appears! (Other tests indicate that the writes to stderr are trashing my address space!) Workaround: If script is as follows, #! /bin/csh (frob) |& cat logfile contains frob: Command not found. THE QUESTION: csh is obviously doing something "smart" with stderr. Just what is going on? Please reply directly to me -- if results are interesting enough, I may post a followup. Thank you in advance... -- 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...