Skip to content

Commit

Permalink
execute: log about failures when opening a terminal to reset
Browse files Browse the repository at this point in the history
  • Loading branch information
poettering committed Oct 25, 2023
1 parent 83d5bba commit adabcba
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/core/execute.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,24 @@ int exec_context_tty_size(const ExecContext *context, unsigned *ret_rows, unsign

void exec_context_tty_reset(const ExecContext *context, const ExecParameters *p) {
_cleanup_close_ int _fd = -EBADF, lock_fd = -EBADF;
const char *path = exec_context_tty_path(ASSERT_PTR(context));
int fd;

assert(context);

const char *path = exec_context_tty_path(context);

if (p && p->stdin_fd >= 0)
fd = p->stdin_fd;
else if (path) {
fd = _fd = open_terminal(path, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
if (fd < 0)
return;
return (void) log_debug_errno(fd, "Failed to open terminal '%s', ignoring: %m", path);
} else
return; /* nothing to do */

/* Take a synchronization lock for the duration of the setup that we do here.
* systemd-vconsole-setup.service also takes the lock to avoid being interrupted.
* We open a new fd that will be closed automatically, and operate on it for convenience.
*/
* systemd-vconsole-setup.service also takes the lock to avoid being interrupted. We open a new fd
* that will be closed automatically, and operate on it for convenience. */
lock_fd = lock_dev_console();
if (lock_fd < 0)
return (void) log_debug_errno(lock_fd,
Expand Down

0 comments on commit adabcba

Please sign in to comment.