Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug#593426: zsh: Status of background jobs not updated
- X-seq: zsh-workers 28174
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Jilles Tjoelker <jilles@xxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Bug#593426: zsh: Status of background jobs not updated
- Date: Thu, 19 Aug 2010 19:36:30 -0700
- Cc: 593426@xxxxxxxxxxxxxxx
- In-reply-to: <20100819221442.GA95791@xxxxxxxx>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20100819221442.GA95791@xxxxxxxx>
On Aug 20, 12:14am, Jilles Tjoelker wrote:
}
} > [continuing a stopped background job using kill is not reflected in the
} > output of jobs]
}
} I think hooking into the kill builtin is the wrong way to fix this.
} Instead, use the facilities provided by modern systems which can notify
} you if a child process continues. These are si_code CLD_CONTINUED for
} SIGCHLD and the WCONTINUED flag and WIFCONTINUED() macro for waitpid().
Zsh *soes* use those facilities.
The problem (if I understand the thread so far correctly) is, in order
to use those facilities, zsh has to wait for the job, i.e., call one of
waitpid() or the like. But the shell doesn't just sit around all day
waiting for background jobs or polling the ones that are stopped to see
if they spontaneously started again -- in fact the whole point is that
it does NOT wait for background jobs.
So unless the OS sends a SIGCHLD when the background job changes state,
zsh isn't aware that it ought to check on the child status. There is
a SIGCHLD sent to the parent when the background job stops, but that
signal is NOT sent when the child resumes running again.
You can even see this for yourself by installing a handler, e.g.,
trap "print CHILD" SIGCHLD
Now run something in the background, kill it with -STOP/-CONT from some
other shell, and watch when CHILD is printed (or isn't).
--
Messages sorted by:
Reverse Date,
Date,
Thread,
Author