FS#12251 - [initscripts] rc.d scripts cannot be called from cron
Attached to Project:
Arch Linux
Opened by Gavin Bisesi (Daenyth) - Wednesday, 26 November 2008, 17:19 GMT
Last edited by Roman Kyrylych (Romashka) - Saturday, 13 February 2010, 16:15 GMT
Opened by Gavin Bisesi (Daenyth) - Wednesday, 26 November 2008, 17:19 GMT
Last edited by Roman Kyrylych (Romashka) - Saturday, 13 February 2010, 16:15 GMT
|
Details
The rc.d scripts can't be called fron cron because of the
way they use stty:
/bin/stty: standard input: Inappropriate ioctl for device |
This task depends upon
Closed by Roman Kyrylych (Romashka)
Saturday, 13 February 2010, 16:15 GMT
Reason for closing: Fixed
Additional comments about closing: patch applied, no response, assuming fixed
Saturday, 13 February 2010, 16:15 GMT
Reason for closing: Fixed
Additional comments about closing: patch applied, no response, assuming fixed
I'm looking at the code now. Is this error critical? From what I see, the scripts should run anyway. This can probably be solved by some reordering of commands, so stty isn't called on a non-terminal.
http://projects.archlinux.org/?p=initscripts.git;a=commitdiff;h=b05933da4de82fe515c1eee5e5a7690072b99c79
Also, my testing shows that tput works fine on non-tty and doesn't spit to stderr either.
Conceivably, you might want to output color when stdout is a terminal but stdin isn't. But then you'd need to find some non-stty-based method for determing the column size. Maybe use $COLUMNS?
if [ -t 1 ]; then
STAT_COL=$(tput cols)
if [ "$STAT_COL" = "0" ]; then
# if output was 0 (serial console), set default width to 80
STAT_COL=80
fi
else
STAT_COL=80
USECOLOR=""
fi
# we use 13 characters for our own stuff
...etc
I don't know how many terminals define the cols attribute. I can attest that at least linux and rxvt-unicode do.
If we want to continue using stty, then as I said please avoid calling it when input is not a terminal (I hit a problem case where input wasn't a terminal but output was minutes after implementing the patch), or please add "2>/dev/null" to the stty call.
http://projects.archlinux.org/?p=initscripts.git;a=commitdiff;h=0e36fec20e3c27eaa459e1083833cb85ccf2b34b
But wasn't paying attention and snuck in an additional patch... fixing that now
to STAT_COL="$(/bin/tput cols 2>/dev/null)". The motivation for doing that was there were times at startup where tput might fail (if, e.g., you have /usr on a separate partition and /etc/rc.d/functions is being sourced before /usr/share/terminfo is mounted. That motivation is good, but the solution I proposed is dumb. When you do VAR=$(cmd), stdout isn't going to the terminal. When you do VAR=$(cmd 2>/dev/null), then stderr isn't going to the terminal either. So VAR=$(tput cols 2>/dev/null) is always going to return 80.
I've attached another fix, which first tries to call tput cols silently to see whether there's an error. If no error, then it calls tput cols for real, no longer redirecting stderr, to get the real width of the terminal.
This patch is in git format, which I've now learned how to do. The current version of functions in git is broken---it looks like these fixes were applied twice, or two versions of them were applied, or something like that. This patch should clean it all up.