You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The opencloud CLI catches SIGINT, SIGTERM, SIGQUIT and SIGHUP for the whole run of a command #4041
The root command creates its context with signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP) and never calls the returned stop function (opencloud/pkg/command/root.go, Execute). The handlers stay installed as long as the process runs. For the commands an admin runs by hand or from cron, that has two effects:
nohup doesn't protect a command from SIGHUP.nohup starts the process with SIGHUP ignored, but signal.Notify installs a handler for an ignored SIGHUP anyway (see the documentation of os/signal). When the terminal session ends, the command's context is cancelled. storage-users revisions cleanup, for example, then stops with "interrupted" and exit code 1.
SIGQUIT no longer dumps the goroutines. Go's default for SIGQUIT is to print the stacks of all goroutines and exit, which helps to see where a hanging command is stuck. Here it only cancels the context, like Ctrl-C.
Steps to reproduce
Run a long-running command with nohup, e.g. nohup opencloud storage-users revisions cleanup --all --dry-run > cleanup.log &.
Close the terminal session, or send the process a SIGHUP.
Expected behavior
The command keeps running, as nohup promises.
Actual behavior
The command stops: The cleanup was interrupted, before all files were cleaned up., exit code 1.
Suggestion
Don't listen to SIGHUP when it is ignored (signal.Ignored(syscall.SIGHUP)), so that nohup works.
Consider leaving SIGQUIT to Go's default handler.
Setup
opencloud main, single binary, posix driver. Every command under the root command is affected.
Activity