Thread View: att.unix
1 messages
1 total messages
Started by Daniel R. Levy
Thu, 19 May 1988 02:23
thanks for help with error message to tty after setpgrp()
Author: Daniel R. Levy
Date: Thu, 19 May 1988 02:23
Date: Thu, 19 May 1988 02:23
22 lines
1631 bytes
1631 bytes
Thanks to all who posted or emailed suggestions for how I might get an error message for a failed exec() back to the terminal that started the command, if I had first closed all tty file descriptors and done a setpgrp(). With the net's guruly help, I have found an answer. I use pipe() to create a (ya guessed it) pipe. I then do a fork(). The child process closes the reading end of the pipe, does a fcntl() on the writing end to make it close-on-exec, then does setpgrp() and tries the exec. The parent, meanwhile, has closed the writing end of the pipe and is listening to the reading end. If the child's exec succeeds, the parent gets an EOF on the pipe (because the other end was closed on the exec) and can go away happy. If the child's exec fails, it writes errno down the pipe, and the parent gets it and prints the corresponding error message to /dev/tty. And there is no need to worry about the name of the controlling terminal. Neat huh??? hack hack hack, -- |------------Dan Levy------------| Path: ihnp4,<most AT&T machines>!ttrdc!levy | AT&T | Weinberg's Principle: An expert is a | Data Systems Group | person who avoids the small errors while |--------Skokie, Illinois--------| sweeping on to the grand fallacy.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads