mirror of
https://github.com/coreutils/coreutils.git
synced 2026-10-28 09:44:34 +08:00
maint: commit-msg: handle reparenting by Linux subreapers
* scripts/git-hooks/commit-msg ($git_pid): Define the parent process ID at the start of the script. Use it to check if we were reparented.
This commit is contained in:
1 parent
75f734b075
commit
9d7b86ed23
1 file changed
+9
-1
@@ -4,6 +4,14 @@ eval '(exit $?0)' && eval 'exec perl -w "$0" ${1+"$@"}'
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Get the process ID of our parent as soon as possible to minimize the
|
||||
# likelihood of our parent dying while we are alive. Note that we don't
|
||||
# check that the parent is init, since on Linux a process may become a
|
||||
# subreaper using PR_SET_CHILD_SUBREAPER, e.g., as done by the
|
||||
# 'systemd --user' process.
|
||||
my $git_pid = getppid ();
|
||||
|
||||
(my $ME = $0) =~ s|.*/||;
|
||||
|
||||
# Emulate Git's choice of the editor for the commit message.
|
||||
@@ -165,7 +173,7 @@ sub check_msg($$)
|
||||
re_edit $log_file;
|
||||
|
||||
# Stop if our parent is killed.
|
||||
getppid() == 1
|
||||
getppid () != $git_pid
|
||||
and last;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user