Fix pid issue

This commit is contained in:
2026-01-14 03:59:36 -08:00
parent 0036be52a9
commit d70c66b24a

View File

@ -116,7 +116,7 @@ int main(int argc, char *const *argv) {
int signal_num = SIGHUP;
bool no_search = false;
bool had_error = false;
pid_t init_ppid = -1;
pid_t init_ppid = 0;
int c;
const char *old_posixly_correct = getenv("POSIXLY_CORRECT");
putenv("POSIXLY_CORRECT=1");
@ -180,12 +180,14 @@ int main(int argc, char *const *argv) {
return 1;
}
// we now check if the parent exited before this point
pid_t new_ppid = getppid();
if (new_ppid != init_ppid) {
raise(signal_num);
// if we got here that means the signal in question was ignored which is
// probably what the user intended, so just go on with execing the new
// process
if (init_ppid > 0) {
pid_t new_ppid = getppid();
if (new_ppid != init_ppid) {
raise(signal_num);
// if we got here that means the signal in question was ignored
// which is probably what the user intended, so just go on with
// execing the new process
}
}
const char *func;
if (no_search) {