Subject: Bug#48542: cron: crontab -e cannot be resumed
From: Steve Greenland (email@example.com)
Date: Sun Nov 07 1999 - 22:05:32 CET
On 28-Oct-99, 00:01 (CDT), Joey Hess <firstname.lastname@example.org> wrote:
> Package: cron
> Version: 3.0pl1-53
> Severity: normal
> If I run "crontab -e" and then suspend it with ctrl -z, and resume, the
> editor gets control long enough to repain the screen, and then iis
> backgrounded again. This happens with jed or vi as the editor used, and with
> bash or zsh as the shell used.
(s/vi/your favorite editor/g in the following)
Ok, I think I know what's happening. When crontab is waitpid()ing for vi
to exit, it also tracks when vi is stopped (via SIGTSTP, which is what
^Z sends). When it sees this, it then tells itself to TSTP.
This is good if someone sends the TSTP to vi via 'kill -TSTP', for
example, because otherwise the crontab process would just sit there,
blocking access to the terminal/shell. It's bad when someone hits ^Z,
because that sends TSTP to all the processes in the group. Then what
happens is this (the order of 1,2 and 3,4 fuzzy, but mostly irrelevant):
1. crontab gets TSTP, and goes into stop mode.
2. vi gets TSTP, and goes into stop mode.
4. vi wakes up.
5. crontab wakes up, looks at the result of the waitpid() that happened
while it was asleep, sees that vi got a TSTP, and sends itself back to
You may not have noticed/tried, but you can at this point hit another
fg, crontab wakes up, and you're back in vi. Unfortunately, the only
useful thing you can do is ':q!', because the terminal is in the wrong
mode. This is because vi reset it correctly when it woke up in step 4,
but bash set it back to cooked mode when it got control back after step
5. When the crontab continues again, vi gets control of the terminal,
but doesn't know it needs to reset the terminal window yet again.
Anyway, what I done is this: crontab will no longer stop itself when vi
does. 99% of the time this will be the correct thing: when you ^Z, both
vi and crontab will stop (because they both get the signal.) However, if
you send TSTP to vi some other way (e.g. kill from another window), then
vi will stop but crontab won't, and it will just look like vi is stuck
in that window.
(I think all this dates back to non-job-control shells, in which case
the ^Z would have only gone to the foreground process (i.e. vi). But
does anybody still use non-job-control shell interactively?)
-- Steve Greenland <email@example.com>
-- To UNSUBSCRIBE, email to firstname.lastname@example.org with a subject of "unsubscribe". Trouble? Contact email@example.com
This archive was generated by hypermail 2b25 : Mon Nov 08 1999 - 23:15:21 CET