0

In a program A, it calls a script B. And in the script B, it calls wpa_supplicant directly (not via this way: systemctl start wpa_supplicant) to config WIFI network. And we found that if the program A is killed, sometimes the network will be disconnected while sometimes the network keeps connected.

program A -> call script B -> call wpa_supplicant

So I want to know why? In my understanding, if the parent process is killed, then the child process will die automatically, right? Why sometimes the network keeps connected? Which means the child process wpa_supplicant is still alive, right?

Tom Xue
  • 3,169
  • 7
  • 40
  • 77
  • Possible duplicate of [Are child processes created with fork() automatically killed when the parent is killed?](https://stackoverflow.com/q/395877/608639) Also see [How to make child process die after parent exits?](https://stackoverflow.com/q/284325/608639) – jww Dec 27 '17 at 18:00
  • In my case, wpa is killed sometimes, while sometimes it keeps alive. How to explain this? According to your reply, I can not find the answer when will the child process be killed. – Tom Xue Dec 28 '17 at 05:26

1 Answers1

1

When the parent process terminates before the child process, the child process remains as a so called orphan process on the system until it terminates. After it terminates, it will become a zombie until it gets reaped by init.

hek2mgl
  • 152,036
  • 28
  • 249
  • 266
  • Thank you for your reply! In my case, wpa is killed sometimes, while sometimes it keeps alive. How to explain this? According to your reply, I can not find the answer when will the child process be killed. – Tom Xue Dec 28 '17 at 05:26
  • It won't get killed. I guess it just terminates itself. Check syslog for the reason. – hek2mgl Dec 28 '17 at 09:27
  • That system uses systemd. But due to wpa is invoked by script, so no journal log. And the test result shows that in 10 test cases, 3 of them will occur WIFI networks disconnected issue, and the rest 7 of them will keep network connected. – Tom Xue Dec 28 '17 at 10:10
  • systemd is unrelated to (r)syslog. Just check `/var/log/syslog` (or `/var/log/messages`, depending on your system) – hek2mgl Dec 28 '17 at 10:46