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
Processes contains the isSuccessfulExitCode method which works well when you are checking the positive case:
if (Processes.isSuccessfulExitCode(exitCode)) {
// handle success
}
But when checking the negative case it would not be too hard to miss the ! in front of Processes assuming you're not using a static import:
if (!Processes.isSuccessfulExitCode(exitCode)) {
// handle a nonzero exit
}
This issue adds a new isNonzeroExitCode method to Processes to specifically indicate the exit code is nonzero, and not necessarily a failure or unsuccessful termination. For example, according to Exit Codes With Special Meanings in TLDP (The Linux Documentation Project), a code of 130 represents termination due to a user pressing CTRL+C. So, is that really a program failure or error? I would argue it's not necessarily a problem with the program, e.g. a user terminates a long-running command using CTRL+C instead of letting it finish normally. In Exit and Exit Status, TLDP also says:
A successful command returns a 0, while an unsuccessful one returns a non-zero value that usually can be interpreted as an error code.
The key word here is usually, leaving room for a nonzero exit code that isn't necessarily an error. So, using the generic isNonzeroExitCode seems like a decent and clear choice here.
So the above "negative" example will now become:
if (Processes.isNonzeroExitCode(exitCode)) {
// handle a nonzero exit
}
The text was updated successfully, but these errors were encountered:
Processes
contains theisSuccessfulExitCode
method which works well when you are checking the positive case:But when checking the negative case it would not be too hard to miss the
!
in front ofProcesses
assuming you're not using a static import:This issue adds a new
isNonzeroExitCode
method toProcesses
to specifically indicate the exit code is nonzero, and not necessarily a failure or unsuccessful termination. For example, according to Exit Codes With Special Meanings in TLDP (The Linux Documentation Project), a code of 130 represents termination due to a user pressing CTRL+C. So, is that really a program failure or error? I would argue it's not necessarily a problem with the program, e.g. a user terminates a long-running command using CTRL+C instead of letting it finish normally. In Exit and Exit Status, TLDP also says:The key word here is usually, leaving room for a nonzero exit code that isn't necessarily an error. So, using the generic
isNonzeroExitCode
seems like a decent and clear choice here.So the above "negative" example will now become:
The text was updated successfully, but these errors were encountered: