I run the command
(Xorg & sleep 3; xeyes) & to test Xorg, and group it into a single subshell background job to make management easy. This works properly, and opens xeyes in the new Xorg session after 3 seconds.
Upon running the command, I'll get an output such as the following:
ps -ef to check new processes, I'll get an output like the following:
root 635 361 0 4:52 tty1 00:00:00 -bash root 636 365 0 4:52 tty2 00:00:00 /usr/lib/Xorg root 639 365 0 4:52 tty1 00:00:00 xeyes
This seems to be a pretty standard output, and as expected.
After verifying my X server works as expected, I attempt to kill this group with
kill %1. Upon running this, my processes now look as follows:
root 636 1 0 4:52 tty2 00:00:00 /usr/lib/Xorg
Why has Xorg failed to exit? Why has the subshell exited successfully, closing xeyes correctly, but not brought Xorg along with it? Why has the parent process of Xorg now changed to 1 instead of the subshell? Shouldn't the subshell send a kill signal to all of its child processes upon exit?
Additionally, if I kill the group instead with
kill 635, which many resources say should be equivalent to
kill %1, my process state is even more bizzare:
root 636 1 0 4:52 tty2 00:00:00 /usr/lib/Xorg root 639 1 0 4:52 tty1 00:00:00 xeyes
What??? Why have both processes failed to exit now, and are now children of PID 1? What's going on here, and what am I doing wrong?
An in-depth explanation of what exactly is going on here would be appreciated, in addition to just telling me what to do instead.