Problem with any of os.system(), os.fork() & os.execp() and os.spawn()

Martin v. Loewis martin at v.loewis.de
Wed Jan 2 16:54:31 EST 2002


Eric Chamberland <Eric.Chamberland at videotron.ca> writes:

> So, I need to have commands in "myscript" to be run in background,
> so how do I make this simple thing work correctly?

This has nothing to do with python. Please try

(sleep 5;/tmp/myscript) &

in your shell. You will see that the same effect happens. If you
strace the shell, you will see that tcsh executes the sequence

...
1912  write(1, "first\n", 6)            = 6
1912  _exit(0)                          = ?
1905  setpgid(1912, 1912)               = 0

This is the fragment where the first subshell exits; 1905 is the tcsh
and 1912 the echo process. Shortly afterwards, you see

1905  write(17, "[1] 1912\n", 9)        = -1 EIO (Input/output error)
1905  munmap(0x40017000, 33577)         = 0
1905  _exit(1)                          = ?

FD 17, in this case, is a dup of stdout. Since the terminal is closed,
the write operation gets a SIGIO. In turn, tcsh decides to exit,
instead of invoking the rest of the script.

So if there is a problem, it is in tcsh. I'd recommend to rewrite this
script in Python.

Regards,
Martin



More information about the Python-list mailing list