From: Karel Zak <kzak@redhat.com>
To: Csaba Kos <csaba.kos@gmail.com>
Cc: util-linux@vger.kernel.org
Subject: Re: [PATCH] deadlock in script
Date: Fri, 30 May 2014 11:15:03 +0200 [thread overview]
Message-ID: <20140530091503.GE9000@x2.net.home> (raw)
In-Reply-To: <CADhtO=98eyzuDjbNgSzfdq17wxwWnuWp5H7-Go-Ut4SvMAQ7hw@mail.gmail.com>
On Fri, May 30, 2014 at 03:30:45PM +0900, Csaba Kos wrote:
> diff --git a/term-utils/script.c b/term-utils/script.c
> index e5d239c..32906d0 100644
> --- a/term-utils/script.c
> +++ b/term-utils/script.c
> @@ -36,6 +36,9 @@
> * - added Native Language Support
> *
> * 2000-07-30 Per Andreas Buer <per@linpro.no> - added "q"-option
> + *
> + * 2014-05-30 Csaba Kos <csaba.kos@gmail.com>
> + * - fixed a rare deadlock after child termination
> */
>
> /*
> @@ -114,6 +117,8 @@ int tflg = 0;
> int forceflg = 0;
> int isterm;
>
> +sigset_t block_mask, unblock_mask;
This declaration shadows declaration in main() where is also block_mask and
unblock_mask -- I guess it's not expected.
> + /* block SIGCHLD */
> + sigprocmask(SIG_SETMASK, &block_mask, &unblock_mask);
the initialization is where? in main()?
> + /* wait for input or signal (including SIGCHLD) */
> + if ((cc = pselect(STDIN_FILENO + 1, &readfds, NULL, NULL, NULL,
> + &unblock_mask)) > 0) {
probably good idea, I have thought about something like this (or
signalfd()), but I have never found time to try it... thanks!
> + if ((cc = read(STDIN_FILENO, ibuf, BUFSIZ)) > 0) {
> + if (write_all(master, ibuf, cc)) {
> + warn (_("write failed"));
> + fail();
> + }
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
next prev parent reply other threads:[~2014-05-30 9:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-30 6:30 [PATCH] deadlock in script Csaba Kos
2014-05-30 9:15 ` Karel Zak [this message]
2014-05-30 9:52 ` Csaba Kos
2014-06-02 9:08 ` Karel Zak
2014-06-02 9:37 ` Ruediger Meier
2014-06-02 9:57 ` Karel Zak
2014-06-02 10:03 ` Ruediger Meier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140530091503.GE9000@x2.net.home \
--to=kzak@redhat.com \
--cc=csaba.kos@gmail.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox