How to find the main process PID without master
identification?
In this case:
[root@4d62e42f3cde conf.d]# ps -ef | grep demosoft
root 1700 1 0 08:34 pts/0 00:00:00 grep --color=auto demosoft
root 26814 1 0 Apr12 ? 00:00:00 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26815 26814 0 Apr12 ? 00:01:33 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26816 26814 0 Apr12 ? 00:01:36 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26817 26814 0 Apr12 ? 00:01:35 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26818 26814 0 Apr12 ? 00:01:32 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26819 26814 0 Apr12 ? 00:01:30 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26820 26814 0 Apr12 ? 00:01:29 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26821 26814 0 Apr12 ? 00:01:29 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26822 26814 0 Apr12 ? 00:01:30 demosoft --config=/etc/demosoft/demosoft.conf
demosoft 26823 26814 0 Apr12 ? 00:01:44 demosoft --config=/etc/demosoft/demosoft.conf
I only know use command:
ps -ef | grep demosoft | awk '{print $2}'
get the PIDs:
1710
26814
26815
26816
26817
26818
26819
26820
26821
26822
26823
I want to send SIGHUP signal to main process. but how?
you know if it is a Nginx process, I can send SIGHUP signal by:
kill -HUP $(ps -ef | grep nginx | grep master | awk '{print $2}')
but demosoft do not have the master identification.
You could install then use the pstree(1) command after having read its documentation.
You could also use the top(1), pgrep(1) and pkill(1) commands after having read their documentation.
You could use signal(7) (see also proc(5) and signal-safety(7)) and several syscalls(2) in your C program (maybe also with nftw(3)...) after having read more documentation and Advanced Linux Programming
On most Linux systems, you may access /proc/
- read carefully proc(5)
You probably want to read documentation related to systemd(1) and credentials(7).
I also recommend reading the documentation of Nginx. Since it is open source software, you are allowed to download its source code then improve it.
You could even (but there is a cybersecurity risk in doing so) write some FastCGI thing to remotely kill(2) processes (or use killpg(2)) thru a web interface, or use libonion to write some webservice doing so, or contribute (in spring or summer 2021) to the RefPerSys project to do so more cleverly