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
// Status represents the running status and consolidated return of a Cmd. It can
// be obtained any time by calling Cmd.Status. If StartTs > 0, the command has
// started. If StopTs > 0, the command has stopped. After the command finishes
// for any reason, this combination of values indicates success (presuming the
// command only exits zero on success):
//
// Exit = 0
// Error = nil
// Complete = true
//
// Error is a Go error from the underlying os/exec.Cmd.Start or os/exec.Cmd.Wait.
// If not nil, the command either failed to start (it never ran) or it started
// but was terminated unexpectedly (probably signaled). In either case, the
// command failed. Callers should check Error first. If nil, then check Exit and
// Complete.
typeStatusstruct {
Cmdstring
PIDint
Completebool// false if stopped or signaled
Exitint// exit code of process
Errorerror// Go error
StartTsint64// Unix ts (nanoseconds), zero if Cmd not started
StopTsint64// Unix ts (nanoseconds), zero if Cmd not started or running
Runtimefloat64// seconds, zero if Cmd not started
Stdout []string// buffered STDOUT; see Cmd.Status for more info
Stderr []string// buffered STDERR; see Cmd.Status for more info
}
Its description mentions that Complete should be false and Error should not be nil if signaled.
But if the underlying cmd receives a os.Interrupt signal, the returned status will have a true value in Complete and a nil value in Error
Reproduce:
test script count_sec.sh
#!/bin/shexit_fn () {
# https://unix.stackexchange.com/questions/447229/how-can-we-set-up-a-signal-trap-to-be-sig-ign-and-sig-dfl-in-bashtrap - INT # Restore signal handling for SIGINTecho;echo'Catch it! Interrupt!'# Growl at user,# Mock# https://unix.stackexchange.com/a/99117exit 130 # then exit script.
}
trap"exit_fn" INT # Set up SIGINT trap to call function.
count=0
while [ "$1"-ne"$count" ]
do
sleep 1
count=$((count +1))echo$countdonetrap - INT # Restore signal handling to previous before exit.
cmd/cmd.go
Lines 108 to 134 in 500562c
Its description mentions that
Complete
should be false andError
should not be nil if signaled.But if the underlying cmd receives a
os.Interrupt
signal, the returned status will have a true value inComplete
and a nil value inError
Reproduce:
test script
count_sec.sh
main function:
The text was updated successfully, but these errors were encountered: