chiark / gitweb /
Subprocess error handling: Initialise $? to -1
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 16 Jul 2016 22:10:27 +0000 (23:10 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 17 Jul 2016 12:46:14 +0000 (13:46 +0100)
When system(3perl) fails due to syscall error, it sets only $!.  When
it succeeds it sets only $? and sometimes trashes $!.  Conversely,
close of a popened filehandle always sets both in all cases.

Document this in a comment.

So when using system and relying on $?/$! (rather than looking at
system's return value), such as when about to use failedcmd, it's
necessary to initialise $? to -1.

Fix the three call sites where system might be followed by failedcmd
but this wasn't done.


No differences found