-
Notifications
You must be signed in to change notification settings - Fork 47
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
Restore shelljob in go-criu #150
Comments
Are you using the |
Yes, I have been trying different options, but essentially these options for dump and restore. I have attached the dump and restore logs.
The dump works fine and I can restore it later on manually from the commandline, but the restore in Go is crashing with mentioned error. If it was confusing, I am trying to also restore it within the same Go program. I attached the parent and child code too. Thanks for the quick response! |
When you start a child process from within the Go code, it does not directly have access to the stdin/stdout/stderr of the TTY from which you are running the main program. You are explicitly setting the "current" stdout/stderr for the child program in the following lines: // newparent.go:149
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr When CRIU is restoring the child process, these file descriptors are not recognised as a terminal/TTY since the child never had direct access to it in the first place (at least, I think this is how it works, my explanation might be wrong). One way to make this work is by using a pipe to connect the stdin/stdout/stderr of the parent process to the child process. // newparent.go:149
_, err := cmd.StdinPipe()
// Handle error
_, err = cmd.StdoutPipe()
// Handle error
_, err = cmd.StderrPipe()
// Handle error Making this change locally allowed me to successfully restore the child from within the parent process, like how you're trying to do. |
Not sure if this is related, but crun uses a callback to get an FD from the restored process from CRIU. I do not think the go interface exposes this callback. I am also not sure it is related. But it reminded me a bit about this request here. Maybe it helps. |
runc also implements something similar using the |
Thanks, It seems like it works. I suspected it was some Go technicality I didn't know or the
Like so, I get the output to the terminal as it comes, but it doesn't seem to continue after the restore. Is there some trick for this too? |
Hi. I restructured the code a bit and I realize that the restored process, though CRIU says it restores successfully, never actually is restored. When SIGSTOP is sent to the process before dump, it revives and lives until a CONT or 2 are sent to it. When I don't send the SIGSTOP on the other hand. CRIU says it restores successfully, but instantly dies, though it is impossible that the process does it on its own. I am really at a loss here. I am quite sure it has to do with the pipes, but am running out of thoughts here. Do you have any ideas why this could be? |
I met the same problem. I created a simple looper process by running a C++ script. It can print numbers in the terminal. The dumping worked fine, but when I tried to restore the process, the same error occured. I can restore it manually by using the 'criu' commandline, but I can not do this in go-criu. |
So I managed to work around this by starting a tty in Go and launching it from there manually. There is probably a better way with some external sockets or something, but I didn't have the capacity to find it then. cmd := exec.Command("/usr/local/sbin/criu", "restore", "-v4", "-o", "restore.log", "-j", "--tcp-established", "-D", checkpointDir) f, err := pty.Start(cmd) |
I am trying to figure out, how to go about restoring shelljobs in go-criu. Inside my Go code, I'm launching a child process and dumping it. When I go to restore it, I get the following error every time.
restore failed: operation failed (msg:Error (criu/tty.c:991): tty: Don't have tty to inherit session from, aborting err:0)
As far as I understand it is trying to inherit the shell session that the Go program is running it, so it fails. Am I missing a simple way to do this? I am setting the shelljob paremeter on both dump and restore, and have also tried setting setsid on the child process, but that isn't doing anything. Thanks!
The text was updated successfully, but these errors were encountered: