]> git.ipfire.org Git - thirdparty/grub.git/commit
osdep/unix/exec: Avoid atexit() handlers when child execvp() fails
authorDimitri John Ledkov <xnox@ubuntu.com>
Thu, 29 Apr 2021 11:34:34 +0000 (12:34 +0100)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 1 Jun 2021 15:20:20 +0000 (17:20 +0200)
commit7da1d0dde1e4a7d37872ece8ef1dd2a68f84b4cc
tree70dd627a0db7cb3a9209f52eba6d3f6dbaaddead
parent80948f532dac7aceecb5267931f3bfa0bae102e9
osdep/unix/exec: Avoid atexit() handlers when child execvp() fails

The functions grub_util_exec_pipe() and grub_util_exec_pipe_stderr()
currently call execvp(). If the call fails for any reason, the child
currently calls exit(127). This in turn executes the parents
atexit() handlers from the forked child, and then the same handlers
are called again from parent. This is usually not desired, and can
lead to deadlocks, and undesired behavior. So, change the exit() calls
to _exit() calls to avoid calling atexit() handlers from child.

Fixes: e75cf4a58 (unix exec: avoid atexit handlers when child exits)
Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/osdep/unix/exec.c