From: Austin S. <te...@of...> - 2003-09-17 18:22:16
|
On Wed, Sep 17, 2003 at 11:12:12AM -0500, Chris Muth wrote: > Hey, > > I haven't the faintest idea. > Perhaps one of the two brilliant minds the suggested the fix could comment? > #close STDIN; close STDOUT; close STDERR; sleep 5; ####################################### # comment out daemonizing code ending here open (LOG_FILE, "> output"); # open log file STDIN, STDOUT, STDERR are handles associates with unix file handles #1, #2, #3. In unix when you open a new file descriptor it uses the first one available. There's a "trick" in Expect where the descriptors are reopened with the new tty in the same order they are closed. By closing them above, weird things begin to happen. First, LOG_FILE takes the STDIN fileno (0). Then the pty gets opened with the next available two filenos, which should be STDOUT and STDERR. Then the child tries to close and reopen filenos 0 and 1 as the terminal, but oops, the parent is expecting to read from the tty on fileno 2, and the child will be writing to 1. Or something like that. Austin |