Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: redirecting stdio/stderr from a suspended then bged job



Michael Barnes writes:
 > This has been bugging me for a while.  How can I suspend a job that is
 > taking longer than I expect and then put it in the background and then
 > redirect stdio and/or stderr to a file (or /dev/null) ?

You can't.  The I/O descriptors are all established before the job is
started the first time, and then once it is running they're completely
under the control of the job itself; the shell can't change them again.

If you think about it, it has to work this way; imagine the havoc that
could be wrought if a process couldn't guarantee that all writes to the
same descriptor are going to go to the same place.

The only thing you can do is to guess what jobs might take a long time,
and redirect their output somewhere when you start them.  If that place
is a file and you later want to see some of the output, you can run
"tail -f" or whatever.

There are some tricks you could play with named pipes or the zsh coproc,
but they all require that the redirection be specified when you first
type out the command.



Messages sorted by: Reverse Date, Date, Thread, Author