From 64f4ab104735590f4cfd981e5e9a9e47cf4df3c7 Mon Sep 17 00:00:00 2001 From: Radim Vansa Date: Mon, 23 Oct 2023 15:08:11 +0200 Subject: [PATCH] Don't put restored process on foreground if we are background process --- criu/tty.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/criu/tty.c b/criu/tty.c index e9b2d47b1..a7f684627 100644 --- a/criu/tty.c +++ b/criu/tty.c @@ -689,7 +689,6 @@ static int tty_set_sid(int fd) static int tty_set_prgp(int fd, int group) { - if (ioctl(fd, TIOCSPGRP, &group)) { #if 1 if (tolerate_tty_error(fd)) { @@ -1066,7 +1065,9 @@ static int pty_open_unpaired_slave(struct file_desc *d, struct tty_info *slave) * the process which keeps the master peer. */ if (root_item->sid != vpid(root_item)) { - if (root_item->pgid == vpid(root_item)) { + if (getppid() != tcgetpgrp(0)) { + pr_debug("Running in background, not setting foreground process"); + } else if (root_item->pgid == vpid(root_item)) { if (tty_set_prgp(fd, root_item->pgid)) goto err; } else {