I have run nginx in the past as a systemd service via systemctl or the service command on non systemd distributions. I recently wondered what would happen though if you just run the nginx command directly on the command line. It works and shows the default nginx web page on localhost:80, but instead of running as a foreground process in the terminal and streaming stdout, the command immediately exits. To be clear there is still an nginx process running on the machine and localhost displays the default page. I just mean that the terminal doesn't block with the nginx command.
Is this because internally the nginx process is performing a double fork of itself to run itself as a daemon process? It seems like this is the case because I ran
sleep 1 &
[1] 2483
to test what the most recently allocated PID was (2483). Then when I ran nginx and then pstree -p, the master nginx process was running with PID 2486. This would make sense if nginx ran with 2484, then forked another nginx process into 2485, and then we had another nginx fork producing PID 2486, with the first two nginx processes ending, leaving only the 2486 process.
Is this correct? If not what is going on?