- 论坛徽章:
- 78
|
回复 7# tonyliuy
实际跟你想的是反的,system成功返回的是0,失败返回的是非0- Since "SIGINT" and "SIGQUIT" are ignored during the execution
- of "system", if you expect your program to terminate on receipt
- of these signals you will need to arrange to do so yourself
- based on the return value.
- @args = ("command", "arg1", "arg2");
- system(@args) == 0
- or die "system @args failed: $?"
- If you’d like to manually inspect "system"’s failure, you can
- check all possible failure modes by inspecting $? like this:
- if ($? == -1) {
- print "failed to execute: $!\n";
- }
- elsif ($? & 127) {
- printf "child died with signal %d, %s coredump\n",
- ($? & 127), ($? & 128) ? 'with' : 'without';
- }
- else {
- printf "child exited with value %d\n", $? >> 8;
- }
复制代码 |
|