summaryrefslogtreecommitdiff
path: root/src/shared/ptyfwd.c
AgeCommit message (Collapse)Author
2017-02-03run: exit early in --pty if service failedLennart Poettering
This reworks systemd-run so that in --pty mode we watch the unit state the way we do it in --wait mode. Whenever we notice that the service is in failed or inactive state finish right-away, but first write all unwritten characters we can read from the master TTY device. This makes sure that when the TTY service fails before it opens the slave PTY device we properly notice that and exit early, so that borked start parameters result in immediate systemd-run failure. Previously, we'd not notice this at all, as a PTY slave that never was opened won't result in POLLHUP events, and we'd hence simply keep reading from it forever. In essence, --pty now enables the same unit watching logic that --wait enables. However, unless --wait is specified we won#t show the final summary, hence the effective difference should be pretty minimal. Fixes: #3915
2017-02-02ptyfwd: set event source description strings for all event sources of a ↵Lennart Poettering
ptyfwd object
2016-10-16tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek
2016-08-22run: optionally, wait for the service to finish and show its resultLennart Poettering
2016-03-05tree-wide: use SET_FLAG() macro to make code more clearAlexander Kuleshov
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-12-06shared: include what we useThomas Hindoe Paaboel Andersen
The next step of a general cleanup of our includes. This one mostly adds missing includes but there are a few removals as well.
2015-11-16tree-wide: sort includesThomas Hindoe Paaboel Andersen
Sort the includes accoding to the new coding style.
2015-10-31nspawn: fix minor memory leakLennart Poettering
When rebooting nspawn containers about 400 times we'd otherwise hit the fd limit and refuse further reboots.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-07machinectl: fix race when opening new shells with "machinectl shell"Lennart Poettering
Previously, we'd allocate the TTY, spawn a service on it, but immediately start processing the TTY and forwarding it to whatever the commnd was started on. This is however problematic, as the TTY might get actually opened only much later by the service. We'll hence first get EIOs on the master as the other side is still closed, and hence considered it hung up and terminated the session. With this change we add a flag to the pty forwarding logic: PTY_FORWARD_IGNORE_INITIAL_VHANGUP. If set, we'll ignore all hangups (i.e. EIOs) on the master PTY until the first byte is successfully read. From that point on we consider a hangup/EIO a regular connection termination. This way, we handle the race: when we get EIO initially we'll ignore it, until the connection is properly set up, at which time we start honouring it.
2015-03-13Use space after a silencing (void)Zbigniew Jędrzejewski-Szmek
We were using a space more often than not, and this way is codified in CODING_STYLE.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
2015-02-18nspawn: when connected to pipes for stdin/stdout, pass them as-is to PID 1Lennart Poettering
Previously we always invoked the container PID 1 on /dev/console of the container. With this change we do so only if nspawn was invoked interactively (i.e. its stdin/stdout was connected to a TTY). In all other cases we directly pass through the fds unmodified. This has the benefit that nspawn can be added into shell pipelines. https://bugs.freedesktop.org/show_bug.cgi?id=87732
2015-01-14ptyfw: add missing error checkLennart Poettering
2015-01-07ptyfwd: simplify how we handle vhangups a bitLennart Poettering
2015-01-07machinectl: make sure that "machinectl login" exits immediately when the ↵Lennart Poettering
machine it is connected to dies
2014-12-23run: add a new "-t" mode for invoking a binary on an allocated TTYLennart Poettering
2014-11-28treewide: use log_*_errno whenever %m is in the format stringMichal Schmidt
If the format string contains %m, clearly errno must have a meaningful value, so we might as well use log_*_errno to have ERRNO= logged. Using: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/' Plus some whitespace, linewrap, and indent adjustments.
2014-11-05shared: ptyfwd - make coverity happyTom Gundersen
Explicitly ignore return value of ioctl to set window size. Fixes CID#1250804 and CID#1250800.
2014-10-31ptyforward: rework PTY forwarder logic used by nspawn to utilize the normal ↵Lennart Poettering
event loop We really should not run manual event loops anymore, but standardize on sd_event, so that we can run sd_bus connections from it eventually.
2014-02-21ptyfwd: reset nonblocking modeLennart Poettering
Apparently bash doesn't turn off non-blocking mode on stdin/stdout when reading from it, so be nice to bash. Ideally bash would do this on its own for robustness reasons, though. https://bugs.freedesktop.org/show_bug.cgi?id=70622
2013-12-18Revert "ptyfwd: make master terminal attributes raw, too"Lennart Poettering
This reverts commit e7d43b3cc30764138c90eaaf95d3d8f49e448890. This broke the console terminal when booting up a container, so let's not do this.
2013-12-18ptyfwd: make master terminal attributes raw, tooLennart Poettering
2013-12-11ptyfwd: Don't set the output prop of stdin, nor the input props of stdout.Luke Shumaker
It was calling cfmakeraw(3) on the properties for STDIN_FILENO; cfmakeraw sets both input and output properties. If (and only if) stdin and stdout are the same device is this correct. Otherwise, we must change only the input properties of stdin, and only the output properties of stdout.
2013-12-11ptyfwd: Set the size of the PTY base on the size of stdout, not stdin.Luke Shumaker
2013-10-31machinectl: add new command to spawn a getty inside a containerLennart Poettering
2013-10-31nspawn: split out pty forwaring logic into ptyfwd.cLennart Poettering