debcrafters-packages team mailing list archive
-
debcrafters-packages team
-
Mailing list archive
-
Message #05512
[Bug 2081328] Re: run-this-one fails on commands that include some regex patterns
Perhaps a better example would be
$ run-this-one /opt/bin/nuke-files --dir /path/to/clean --files-
regex "tmp|swp"
for a fictitious program named nuke-files that takes a directory to
watch and clean up and a --files-regex argument of what filenames to
delete. This command would remove all files that contain the strings
'tmp' or 'swp' in them, perhaps using 'grep' under the hood.
There is no goal to have run-this-one interpret this "tmp|swp" argument
as a regular expression so it can match multiple processes - it should
be a straight string match.
The problem is when run-this-one comes along with pgrep then this string *IS* considered a regex and matches more processes than it should - notably the run-this-one program itself is matched, which then gets whacked.
The linked PR just protects run-this-one from killing itself. It could
still kill other matches (i.e. it's not a perfect fix) but at least we
will run the program we're hoping to run - without a fix you can never
run a command containing a regex like this because run-this-one kills
itself before executing the intended program.
--
You received this bug notification because you are a member of
Debcrafters packages, which is subscribed to run-one in Ubuntu.
https://bugs.launchpad.net/bugs/2081328
Title:
run-this-one fails on commands that include some regex patterns
Status in run-one package in Ubuntu:
Triaged
Bug description:
pgrep could get confused when the command contains regular expressions
that match the run-* command itself, e.g. an argument like "run-this-
one foo 'a|b'"
PR at https://github.com/dustinkirkland/run-one/pull/1
----- Copied from PR (formatting suffers) -----
$ cat /tmp/sleepforever
#!/bin/bash
echo Sleeping for 99 days...
sleep +99d
# version in HEAD
$ run-this-one /tmp/sleepforever
Sleeping for 99 days...
<ctrl-c>
$ run-this-one /tmp/sleepforever "a|b"
Terminated
Run with -x you find the problem is this:
+ base=run-this-one
+ ps=/tmp/sleepforever a|b
+ pgrep -u wbagg -f ^/tmp/sleepforever a|b$
+ kill 768759
Terminated
pgrep is matching our run-this-one command and itself. The $$ check verifies that we don't kill run-this-one, the ps addition assures we don't kill the (no longer running) pgrep.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/run-one/+bug/2081328/+subscriptions