summaryrefslogtreecommitdiffstats
path: root/term-utils/script.c
Commit message (Collapse)AuthorAgeFilesLines
...
* script: move timing file opening close to use of itSami Kerola2015-06-081-14/+17
| | | | | | | | This allows removing almost immediate closure of file handle in the doshell() function that does not use the file. Proposed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: add noreturn function attributesSami Kerola2015-06-081-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: use gettime_monotonic() to get timing file timestampsSami Kerola2015-06-081-12/+12
| | | | | | | | This moves the previous time to script control structure, and does timeval calculation with timersub() that is more appropriate than making a timeval to a double. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: use correct input type, move comment, and so onSami Kerola2015-06-081-13/+11Star
| | | | | | Minor corrections. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: replace strftime() workaround with CFLAGS = -Wno-format-y2kSami Kerola2015-06-081-12/+3Star
| | | | | | | | Nowadays, gcc(1) provides the -Wno-format-y2k option to prevent the warning, so that the above workaround is no longer required. Reference: http://man7.org/linux/man-pages/man3/strftime.3.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: move do_io() content to small functionsSami Kerola2015-06-081-50/+58
| | | | | | The do_io() got to be a bit long with relatively deep indentation. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: add 'Script started' line always to capture fileSami Kerola2015-06-081-5/+3Star
| | | | | | | | | | | | | | The scriptreplay(1) will expect capture file always to have header. Before this change the --quiet option together with timing caused following replay error. $ script --quiet --timing=timing [...] $ scriptreplay timing typescript [...] scriptreplay: unexpected end of file on typescript Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: remove io vs signal raceSami Kerola2015-06-081-7/+13
| | | | | | | | | | | | Make do_io() to run poll() until all streams are empty. This should remove the signal from child versus io handling race for good. Addresses: https://github.com/karelzak/util-linux/pull/62 Addresses: https://bugs.launchpad.net/bugs/264967 Addresses: https://bugs.debian.org/305808 CC: Wolfgang Richter <wolf@cs.cmu.edu> CC: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: merge doinput() and output() functions to do_io()Sami Kerola2015-06-081-172/+59Star
| | | | | | | | | | One item to poll() more is a lot less work for system than separete input and output processes. Addresses: https://github.com/karelzak/util-linux/pull/62 CC: Wolfgang Richter <wolf@cs.cmu.edu> CC: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: use poll() rather than select()Sami Kerola2015-06-061-88/+114
| | | | | | | | | Finalize the signalfd() change by adding file descriptors to poll() loop. Addresses: https://github.com/karelzak/util-linux/pull/62 CC: Wolfgang Richter <wolf@cs.cmu.edu> CC: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: use signalfd() to catch signalsSami Kerola2015-06-061-33/+14Star
| | | | | | | | | | This is incomplete change. Working command requires the subsequent select() to poll() change as well. Addresses: https://github.com/karelzak/util-linux/pull/62 CC: Wolfgang Richter <wolf@cs.cmu.edu> CC: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: add struct script_control and remove global variablesSami Kerola2015-06-061-244/+249
| | | | | | Fix also couple indentation issues. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: remove function prototypesSami Kerola2015-06-061-256/+243Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* tests: check script options work as expectedSami Kerola2015-06-061-2/+19
| | | | | | | Options --flush and --timing remain unchecked, as I do not have an idea how to check them reliably. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: Fix mangled EOF and hang on big endianStanislav Brabec2015-05-151-2/+2
| | | | | | | | | | | On s390 and other big endian machines, doinput() sends NUL instead of EOF to the tty master. NUL does not even reach the slave, and it is waiting for more data forever. If STDIN is not a tty, the bug caused "^@" being into the log, and since commit 032228c it also causes hang. Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
* Fix "Script started" buffering raceStanislav Brabec2015-02-101-0/+1
| | | | | | | | | | | | | | | script -c "echo Hallo World" </dev/null >script.log ; cat script.log Before: Hallo World Script started, file is typescript Script started, file is typescript Script done, file is typescript After: Script started, file is typescript Hallo World Script done, file is typescript
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+3
| | | | | | | | | This adds a concise description of a tool to its usage text. A first form of this patch was proposed by Steven Honeyman (see http://www.spinics.net/lists/util-linux-ng/msg09994.html). Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* script: may be hangsAndreas Henriksson2014-10-141-4/+11
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: use usage() text element macrosSami Kerola2014-10-011-2/+2
| | | | | | | Translating these text elements should happen only once, which is more likely when the text macros are used properly. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use manual tail usage() macroSami Kerola2014-10-011-0/+1
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* textual: use version printing macro everywhereSami Kerola2014-10-011-2/+1Star
| | | | | | | Only mount, umount, and blkid remains not using the macro because they are print also library references. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: clean up code to genenrate Star/Done messagesKarel Zak2014-06-231-9/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: silence the done message on --quiet as wellAndreas Henriksson2014-06-231-1/+2
| | | | | | | | | | Apparently James Hunts patch (which he provided a long time ago) is no longer covering it all. This followup patch also silences the "Script done ..." message when --quiet is used. Signed-off-by: Andreas Henriksson <andreas@fatal.se>
* script: --quiet option is not quiet.James Hunt2014-06-231-1/+2
| | | | | | | | | | | Specifying 'script --quiet ...' still produces the 'Script started' message in the typescript file. The --quiet option implies that the script program should not log any of its output to the typescript file. Originally reported at: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=693966 Signed-off-by: Andreas Henriksson <andreas@fatal.se>
* docs: fix "behaviour" vs. "behavior"Karel Zak2014-06-061-1/+1
| | | | | | | | Sometimes we use "behaviour" and "behavior" in the same text, let's use "behavior" only everywhere. Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1011068 Signed-off-by: Karel Zak <kzak@redhat.com>
* script: fix spurious exit from input read loop on EINTR.Csaba Kos2014-06-021-1/+2
|
* script: fix a rare deadlock after child terminationCsaba Kos2014-06-021-8/+45
|
* script: time from end of read() call partially fixes #58Wolfgang Richter2014-03-201-2/+3
|
* script: clean up files usageKarel Zak2014-02-211-28/+40
| | | | | | | | | | | | | | | * don't initialize timingfd (to stderr) when -t not specified * care about timingfd dooutput() rather in main() * make timingdf gloval like fscript FILE * close all in done() * close irrelevant things in subshell and input processes Reported-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* script: Also flush writes to timing file.Jesper Dahl Nyerup2014-02-211-1/+4
| | | | | | | | | If both -f and -t are given, flush the timing fd on each write, similar to the behavior on the script fd. This allows playback of still-running sessions, and reduces the risk of ending up with empty timing files when script(1) exits abnormally. Signed-off-by: Jesper Dahl Nyerup <nyerup@one.com>
* script: use all-io.h to make the code more robustKarel Zak2014-01-161-9/+5Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: fix inconsistent -q, use poll() rather then O_NONBLOCKKarel Zak2014-01-161-25/+17Star
| | | | | | | | | - don't suppress "Script done" message in typescript file by -q (note that -q has no effect to "Script started" message) - simplify the code by poll() Signed-off-by: Karel Zak <kzak@redhat.com>
* script: don't wait for empty descriptors if child is deadKarel Zak2014-01-161-4/+8
| | | | | | | | The current code waits for empty file master and slave descriptors, but it makes sense only if there is child process that cares (read) about data in the descriptors. Signed-off-by: Karel Zak <kzak@redhat.com>
* script: script input redirection / eof handlingKarel Zak2013-12-031-19/+79
| | | | | | | | | | | | | | | | | | | | | | | echo "ps uf" | script does not work because script assume that stdin is terminal and it does not forward EOF to the pty. This patch: * make non-tty use-case more robust (don't call tty ioclts to non-tty file descriptors. * send EOF (CTL('D') control char) to the master channel when detected eof by read() on stdin * wait for empty master and slave file descriptors to be sure that we don't miss date for typescript. This is also necessary to be sure that slave channel (shell) is completely initialized otherwise EOF is ignored. Reported-by: Phillip Susi <psusi@ubuntu.com> Signed-off-by: Karel Zak <kzak@redhat.com>
* script: check that stdin is a terminalKarel Zak2013-12-021-0/+4
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: restore errno in signal handlerKarel Zak2013-11-141-0/+3
| | | | | References: https://plus.google.com/+LennartPoetteringTheOneAndOnly/posts/gHSscCJkakd Signed-off-by: Karel Zak <kzak@redhat.com>
* script: don't call TIOCGWINSZ in signal handlerKarel Zak2013-11-141-3/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* script: use __noreturn__ for really last function [clang -Winvalid-noreturn]Karel Zak2013-03-201-4/+4
| | | | | | Use 'noreturn' for done() only. Signed-off-by: Karel Zak <kzak@redhat.com>
* textual: spell and encode the name of Arkadiusz Miƛkiewicz correctlyBenno Schulenberg2013-02-061-1/+1
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* script: search shell from path, when necessarySami Kerola2013-01-091-5/+11
| | | | | Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=518532 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: do not try to close stderr twiceSami Kerola2012-11-081-3/+5
| | | | | | | | | | | | | | | The commit cdd2a8c360c70d16804ace7cc923a6c6bb7c9ca9 broke script(1) return value. $ script -e -c "echo"; echo $? 1 The reason, as Daniel it reported, was that the script will close stderr twice, once as timing file and atexit() in function close_stdout(). This commit fixes the problem. Reported-by: Daniel Narvaez <dwnarvaez@gmail.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: add noreturn function attributesSami Kerola2012-07-261-5/+5
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify file open error messagesSami Kerola2012-07-161-3/+3
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: remove unused codeKarel Zak2012-06-211-10/+0Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* build: fix redundant redeclaration warningsSami Kerola2012-06-111-1/+0Star
| | | | | | | | | | | | | | | | | | | | | | | | | env.c:24:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls] su.c:81:15: warning: redundant redeclaration of 'environ' [-Wredundant-decls] fstab.c:581:14: warning: redundant redeclaration of 'strsignal' [-Wredundant-decls] kill.h:1:13: note: previous declaration of 'get_pids' was here kill.c:152:13: warning: redundant redeclaration of 'get_pids' [-Wredundant-decls] kill.c:142:5: warning: redundant redeclaration of 'main' [-Wredundant-decls] getopt.c:89:5: warning: redundant redeclaration of 'main' [-Wredundant-decls] agetty.c:536:15: warning: redundant redeclaration of 'optarg' [-Wredundant-decls] agetty.c:537:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls] script.c:161:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls] wall.c:96:13: warning: redundant redeclaration of 'optind' [-Wredundant-decls] libmount.h:362:26: note: previous declaration of 'mnt_update_get_fs' was here libmount.h:454:26: note: previous declaration of 'mnt_context_get_fs' was here mountP.h:383:26: warning: redundant redeclaration of 'mnt_context_get_fs' [-Wredundant-decls] mountP.h:398:26: warning: redundant redeclaration of 'mnt_update_get_fs' [-Wredundant-decls] Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* term-utils: verify writing to streams was successfulSami Kerola2012-04-041-4/+12
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: error in usage() outputSami Kerola2012-04-021-1/+1
| | | | | | | Error originates to commit 3ff526391fb5c6b33418dc9cfec31c2ff9b4792e which is bit more than year, and part or releases v2.20 & v2.21. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* script: play well with csh when invoked from within /etc/csh.loginKarel Zak2012-03-081-0/+10
| | | | | Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=797888 Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: check HAVE_ definitions with #ifdef [smatch scan]Sami Kerola2011-12-021-8/+4Star
| | | | | | | | | | Fix to `warning: undefined preprocessor identifier' messages. [kzak@redhat.com: replace "#ifdef XXX #ifdef YYY" with "#if defined(XXX) && defined(YYY)"] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* build-sys: check HAVE_ definitions with #ifdef [smatch scan]Sami Kerola2011-12-021-3/+7
| | | | | | Fix to `warning: undefined preprocessor identifier' messages. Signed-off-by: Sami Kerola <kerolasa@iki.fi>