From: Bernhard Voelker <mail@bernhard-voelker.de>
To: kerolasa@gmail.com
Cc: util-linux <util-linux@vger.kernel.org>
Subject: Re: [PATCH 4/7] tests: check kill is converting signals names correctly
Date: Tue, 15 Apr 2014 11:09:16 +0200 [thread overview]
Message-ID: <534CF73C.50309@bernhard-voelker.de> (raw)
In-Reply-To: <CAG27Bk1pgj3QeLgcUCP05h0QnLsLXibQVkFj3egQbG1nmxew3Q@mail.gmail.com>
On 04/14/2014 09:00 PM, Sami Kerola wrote:
> On 14 April 2014 17:14, Bernhard Voelker <mail@bernhard-voelker.de> wrote:
> Most of the tests could use pid, but I am afraid there should be at
> least one of them using name. Else killing by name remains untested.
What about creating a test 'kill_by_name', and avoiding complexity
in the other tests? They all have a certain purpose each, so there's
no need to put a certain aspect into all of them.
> Of course simple kill by name test could do the job, but I am not
> hugely in favor to simplify tests until they work without
> understanding why they fail in first place.
Agreed. Unfortunately, I didn't find *the* reason for the failure yet.
BTW, I often see both "all_processes" and "name_to_number" failing here.
It seems that there are several issues.
First of all, this looks odd in the receiver program:
> + if (!stat(argv[1], &statbuf)) {
> + if (S_ISDIR(statbuf.st_mode))
> + xasprintf(&pid_path, "%s/%d", argv[1], getpid());
> + } else
> + xasprintf(&pid_path, "%s", argv[1]);
What if the argv[1] is stat()able but not a directory?
Anyway, I'm 40:60 against letting the receiver program decide where
the witness file is located, i.e. I'd rather use deterministic names
everywhere. E.g. in the 'name_to_number' tests, the name of the witness
files could contain the signal name rather than using unsafe mktemp.
Furthermore, the open() call would return -1 upon failure instead
of 0 as assumed here:
> + if (!(fd = open(pid_path, O_WRONLY | O_CREAT | O_TRUNC, mode)))
> + err(EXIT_FAILURE, "cannot open pid file: %s", pid_path);
Re. the "all_processes" test: I'm not sure how su(1) and the intermediate
shell change the signal handling. Maybe the reason for the failure is
somehow related to this, because $! will refer to the shell's PID rather
than to that of the receiver program.
Anyway, maybe it's better to use $TS_CMD_SU instead of the local 'su',
or even adding a dedicated setuid() helper.
As already said, these are just side notes.
Have a nice day,
Berny
next prev parent reply other threads:[~2014-04-15 9:11 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-12 10:28 [PATCH 0/7] kill: add regression tests Sami Kerola
2014-04-12 10:28 ` [PATCH 1/7] kill: make options --pid and --queue mutually exclusive Sami Kerola
2014-04-12 15:57 ` Bernhard Voelker
2014-04-12 16:35 ` Sami Kerola
2014-04-12 10:28 ` [PATCH 2/7] kill: remove unnecessary indirection Sami Kerola
2014-04-12 10:28 ` [PATCH 3/7] tests: add signal receiver program Sami Kerola
2014-04-12 10:28 ` [PATCH 4/7] tests: check kill is converting signals names correctly Sami Kerola
2014-04-13 22:22 ` Bernhard Voelker
2014-04-14 7:42 ` Sami Kerola
2014-04-14 15:13 ` Sami Kerola
2014-04-14 16:14 ` Bernhard Voelker
2014-04-14 19:00 ` Sami Kerola
2014-04-15 9:09 ` Bernhard Voelker [this message]
2014-04-15 11:08 ` Sami Kerola
2014-04-12 10:28 ` [PATCH 5/7] tests: check various ways to specify kill signal Sami Kerola
2014-04-12 10:28 ` [PATCH 6/7] tests: check kill print pid option Sami Kerola
2014-04-12 10:28 ` [PATCH 7/7] tests: check kill all user processes Sami Kerola
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=534CF73C.50309@bernhard-voelker.de \
--to=mail@bernhard-voelker.de \
--cc=kerolasa@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