Closed ikegami closed 3 weeks ago
[snip]
The command is very simple:
/bin/tiffdump foo 2>&1
wherefoo
is a file name with no quotes or other special characters. This would qualify it for the shell-bypass optimization.
I looked for tiffdump
on Ubuntu but the only packages returned by apt-cache search tiffdump
, once installed, did not produce a page for man tiffdump
. Suggestions? (However, on my FreeBSD machine I get such a man page.)
I don't see how the specific command could matter.
In fact, if I remove the die
I added for debugging, a later qx
in the same process exhibits the same problem, and it runs perl
Anything interesting from strace -f
?
Actually, do you have a $SIG{CHLD}
handler (or IGNORE
) somewhere?
Anything interesting from
strace -f
?
No.
70551 read(6, <unfinished ...>
70583 <... exit_group resumed>) = ?
70583 +++ exited with 0 +++
70551 <... read resumed>"", 8192) = 0
70551 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=70583, si_uid=203, si_status=0, si_utime=0, si_stime=0} ---
70551 rt_sigreturn({mask=[]}) = 0
70551 fstat(6, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
70551 close(6) = 0
70551 wait4(70583, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 70583
70551 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
70551 wait4(-1, 0x7ffd274dcb84, WNOHANG, NULL) = -1 ECHILD (No child processes)
70551 rt_sigprocmask(SIG_UNBLOCK, [CHLD], NULL, 8) = 0
70551 write(2, "Failed tifPages: /tmp/1712586111"..., 90) = 90
70551 write(2, "\n", 1) = 1
(The message is slightly different than in the OP because the exception is caught and printed.)
Actually, do you have a
$SIG{CHLD}
handler (orIGNORE
) somewhere?
This just occurred to me too
...and you know what, a quick look indicates there might be one! I need to step out for an appointment, so I'll report back this evening.
Actually, going back the strace, that looks more like a SIGCHLD handler than qx.
And I've confirmed it. There is a SIGCHLD handler being called.
Perl 5.36.0. Linux. A use of
qx
in scalar context is returning a defined value, sets$?
to-1
, and sets$!
to0
.qx
, likesystem
, sets$?
.A positive value indicates the child ran, and it was killed by a signal or it exited with a non-zero exit code.
A zero value indicates indicates the child ran, it wasn't killed by a signal, and it exited with exit code zero.
A negative value indicates the child couldn't be executed. The error could be the execution of the child itself, or some other system call performed in preparation (e.g.
fork
).This means it's impossible for
$?
to be-1
whenqx
returns a defined value. ...Except that is what I am experiencing. The child executed,qx
returned its output, but$?
is set to-1
. Worse,$!
should be set to an error code when$?
is-1
, but it's0
(no error).While 100% reproducible, I can't replicate this using a one-liner. The following is nested in a larger program, which I haven't been able to reduce to a runnable demonstration.
Output:
The odd thing is that this block is executed twice, and it only dies on the second pass.
The command is very simple:
/bin/tiffdump foo 2>&1
wherefoo
is a file name with no quotes or other special characters. This would qualify it for the shell-bypass optimization.I did not find any
local $?
, and I confirmed the magic is still present on$?
.