Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't put restored process on foreground if we are background process #14

Open
wants to merge 1 commit into
base: crac
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions criu/tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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)) {
Comment on lines +1068 to +1070
Copy link
Member

@AntonKozlov AntonKozlov Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay with reply.

This is not a simple change as it involves the state on checkpoint and the state on restore. So we are not restoring control group if restore runs in background.

  1. Is it possible that we now leave some states where we should still be foreground? E.g. restoring in subshell like
$ ( ( java -XX:CRaCRestoreFrom= ... ) ) 

(no &, but parent probably not a foreground?)

  1. Can restoring in background negatively impact java process which may assume foreground?

  2. If the job moved to foreground (`java -XX:CRaCRestoreFrom= ... & ; fg), does it work correctly?

if (tty_set_prgp(fd, root_item->pgid))
goto err;
} else {
Expand Down