#117 No longer trap signal 0 (reserved) and 17 (SIGCHLD) in rpminfo
Opened by colorfulrune. Modified
colorfulrune/rpmdevtools main  into  main

Download 117.patch

Signal number 0 is reserved for use as kill(pid, 0), to test whether a
process exists without sending it a signal, we shouldn't trap this signal.

Signal number 17 (SIGCHLD) is triggered at least once during each bash fork
subprocess, and associating this signal with cleanup code through a trap can
cause rpminfo to unexpectedly trigger cleanup (and exit with error code -1).

0 is valid, it traps on the script exiting.

0 is valid, it traps on the script exiting.

Trap 0 is invaild in this cleanup code, because cleanup code exit with error code -1

# bash -c 'trap "echo get 0" 0; exit 0;'
get 0

Or further

# bash -c 'trap "exit -1" 0; exit 0;'; echo $?
255

When process exit, signal 0 is triggered, sometimes cleanup code will finished and error code will be -1, for example rpminfo -P gcc; echo $? will print 255 (-1).

Also I don't think it's right to trigger cleanup code by catch signal 0.

for example rpminfo -P gcc; echo $? will print 255 (-1).

This is based on ignore signal 17 (SIGCHLD), otherwise almost all commands will fail.

1 new commit added

  • Avoid triggering cleanup code through signal 0 when the rpminfo exit normally

I have updated a patch, and I think it is now the result we all expected. It can trigger cleanup code and return error code -1 when rpminfo exits abnormally, and only do cleanup when rpminfo exits normally without changing the original error code (0).

Metadata