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