qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Peter Xu <peterx@redhat.com>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org,
	Paolo Bonzini <pbonzini@redhat.com>,
	Andrew Jones <drjones@redhat.com>
Subject: Re: [Qemu-devel] [kvm-unit-tests PATCH 2/2] run_tests: allow run tests in parallel
Date: Thu, 5 Jan 2017 21:31:51 +0100	[thread overview]
Message-ID: <20170105203150.GE29430@potion> (raw)
In-Reply-To: <20170105023539.GM22664@pxdev.xzpeter.org>

2017-01-05 10:35+0800, Peter Xu:
> On Wed, Jan 04, 2017 at 03:55:42PM +0100, Radim Krčmář wrote:
>> > I didn't notice the "-n" parameter for "wait", otherwise I won't
>> > bother using SIGUSR1 at all. :)
>> 
>> (Btw. why couldn't you use SIGCHLD?)
> 
> My understanding:
> 
> SIGCHLD is used by internal bash. For every command we write (like a
> "ls" in the script), we should have forked another process to load the
> "/bin/ls" binary, and when this command (in this case "ls") finishes,
> it'll send one SIGCHLD to the main process. This should happen for
> each non-builtin bash commands, and bash program is managing these
> SIGCHLDs internally by default. So, we should not be able to trap
> SIGCHLD in bash.
> 
> There is one way to trap it, only if we provide:
> 
>   set -m
> 
> to turn off the job controls of bash.

I think that "-m" enables job control, but I didn't know it can be
disabled.  I don't understand what bash does with +m -- bg/fg/&/^Z work
just as one would expect of job control, but not SIGCHLD.

>                                       However if with that, we'll
> trigger the SIGCHLD handler for *every* task we run, even for the
> normal commands like "ls". I suppose that's not what we want (we want
> to only trap those background $QEMU processes). That's why I used
> SIGUSR1 instead of SIGCHLD.

I see, it is a more robust, but signals can race, so we couldn't depend
on their count anyway.  And wow, we really get SIGCHLD for foreground
processes ... it wouldn't matter because the loop only uses builtins,
but it is stupid.  (I confess I don't usually use POSIX shells.)

> Of course, after I know "wait -n", it becomes clumsy. :-)

"clumsy" is still a praise for bash code. :)

  reply	other threads:[~2017-01-05 20:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-01 10:34 [Qemu-devel] [kvm-unit-tests PATCH 0/2] run_tests: support concurrent test execution Peter Xu
2017-01-01 10:34 ` [Qemu-devel] [kvm-unit-tests PATCH 1/2] run_tests: provide RUNTIME_log_file Peter Xu
2017-01-01 10:34 ` [Qemu-devel] [kvm-unit-tests PATCH 2/2] run_tests: allow run tests in parallel Peter Xu
2017-01-02 20:18   ` Radim Krčmář
2017-01-03  2:45     ` Peter Xu
2017-01-04 14:55       ` Radim Krčmář
2017-01-05  2:35         ` Peter Xu
2017-01-05 20:31           ` Radim Krčmář [this message]
2017-01-02 17:07 ` [Qemu-devel] [kvm-unit-tests PATCH 0/2] run_tests: support concurrent test execution Paolo Bonzini
2017-01-02 20:25   ` Radim Krčmář
2017-01-03  2:50     ` Peter Xu
2017-01-03  3:03   ` Peter Xu
2017-01-03  9:31     ` Paolo Bonzini

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=20170105203150.GE29430@potion \
    --to=rkrcmar@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).