Closed FLAGLORD closed 3 months ago
Thanks for the report. I'll look into it.
Ah, SIGINT: it doesn't terminate a problem, just interrupts it. https://www.gnu.org/software/bash/manual/html_node/Signals.html
In this case, the shell script above catches that and ends the program. So the go-cmd result is correct: no error, no (handled) signal, completed, and exit status = 130.
The docs mention,
but was terminated unexpectedly (probably signaled)
The subtleness there is "unexpectedly". Catching SIGINT and terminating is not unexpected. (For example, the program could catch and keep running, instead.)
I added https://github.com/go-cmd/cmd/commit/0986371b94ede55e7b15935095bf7c60c15b50c7 to address this for future users.
https://github.com/go-cmd/cmd/blob/500562c204744af1802ae24316a7e0bf88dcc545/cmd.go#L108-L134 Its description mentions that
Complete
should be false andError
should not be nil if signaled. But if the underlying cmd receives aos.Interrupt
signal, the returned status will have a true value inComplete
and a nil value inError
Reproduce:
test script
count_sec.sh
main function: