From: Oleg Verych <olecom@flower.upol.cz>
To: "Herbert Xu (in dash list)" <dash@vger.kernel.org>
Subject: Re: job control (Re: dash race)
Date: Tue, 29 Apr 2008 17:51:54 +0200 [thread overview]
Message-ID: <20080429155154.GP24008@flower.upol.cz> (raw)
In-Reply-To: <E1JqqRh-0005R5-00@gondolin.me.apana.org.au>
> >> >Also, `ps` && `kill` is better implementation of job control. dash's
> >> >interactivity isn't a good one, so what reason is behind shell's job
> >> >control after all?
[...]
> > You don't understand, that `wait` and job control is interactive shell
> > features adopted from Korn Shell?
>
> I use this construct all the time in my scripts so I certainly
> consider this to be a grave bug in dash :)
And if it's really so, your scripts are waiting indefinitely (or forever)
or consume all CPU (with such bugs)?
It is signal-related. Clear example of useless and buggy stuff, that
is used my many without much knowledge.
== bug: `wait` returns non zero if `trap` is not empty ==
(counting is done by keyboard to show, that `wait` actually waits)
olecom@flower:~$ test_script='
(sleep 2; echo kill; kill -1 $$)&
echo do wait;
wait || ps hc -t `tty`
'
olecom@flower:~$ bug='
trap ":" 1;
'$test_script
olecom@flower:~$ dash -c "$bug"
do wait
1
2
kill
4256 pts/15 Ss 0:00 bash
4475 pts/15 S+ 0:00 dash
4479 pts/15 R+ 0:00 ps
olecom@flower:~$ 1
bash: 1: command not found
olecom@flower:~$ 2
bash: 2: command not found
olecom@flower:~$
olecom@flower:~$ notrap='
trap "" 1;
'$test_script
olecom@flower:~$ dash -c "$notrap"
do wait
1
2
kill
olecom@flower:~$ 1
bash: 1: command not found
olecom@flower:~$ 2
bash: 2: command not found
olecom@flower:~$
That's why, i'd advise to use `ps` and/or procfs to poll execution
results right from the kernel; `kill` to terminate or clear processes.
Simply and reliable (at least for scripts).
== m flag ==
olecom@flower:~$ dash +m -c "$b"
do wait
1
2
kill
4256 pts/15 Ss 0:00 bash
4487 pts/15 S+ 0:00 dash
4491 pts/15 R+ 0:00 ps
olecom@flower:~$ 1
bash: 1: command not found
olecom@flower:~$ 2
bash: 2: command not found
olecom@flower:~$ dash +m -c "$s"
do wait
1
2
kill
olecom@flower:~$ 1
bash: 1: command not found
olecom@flower:~$ 2
bash: 2: command not found
olecom@flower:~$
I.e. it doesn't work.
> Unfortunately I'm awfully busy right now but I'll try to reproduce
> it once I get a chance. If anyone can get me a patch before then
> it'd be much appreciated :)
It's better to design select()-like thing, as Peter did for `read`.
Document it. Remove job control. No joking.
____
next prev parent reply other threads:[~2008-04-29 15:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-25 12:39 dash race Alexey Gladkov
2008-04-25 13:45 ` Oleg Verych
2008-04-25 14:37 ` Alexey Gladkov
2008-04-25 16:17 ` job control (Re: dash race) Oleg Verych
2008-04-27 11:23 ` Alexey Gladkov
2008-04-27 11:49 ` Oleg Verych
2008-04-27 19:18 ` Alexey Gladkov
2008-04-29 12:20 ` Herbert Xu
2008-04-29 14:04 ` Herbert Xu
2008-04-29 15:51 ` Oleg Verych [this message]
2009-02-22 10:19 ` Herbert Xu
2008-04-27 20:35 ` Oleg Verych
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=20080429155154.GP24008@flower.upol.cz \
--to=olecom@flower.upol.cz \
--cc=dash@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