csh Rerouting stderr
D. Jason Penney
penneyj at servio.UUCP
Thu May 11 03:56:49 AEST 1989
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...
More information about the Comp.unix.questions
mailing list