Date: Fri, 14 Jul 2017 18:25:32 +0200 From: Edgar =?iso-8859-1?B?RnXf?= <e...@math.uni-bonn.de> Message-ID: <20170714162532.gj50...@trav.math.uni-bonn.de>
| Perhaps I should state more clearly what my questions are | -- is the re-parenting to PPID 1 just to have someone wait()? Yes. But this is just how the system works, there's nothing magic or special happening here, any process whose parent dies gets reparented to init. | -- what exactly is the point (save sanity) of redirecting stdXXX to /dev/null? sanity. | -- which flags to open() /dev/null with for stdXXX? doesn't matter, the idea is that they don't get used - O_RDONLY for all of them makes some sense, reading /dev/null simply gives EOF and the process will (usually) read no more, writing to it would give an error, which is probably the best outcome. | -- is opening /dev/null and dup2()ing to stdXXX just an optimization? Yes. Simpler for the process, and saves kernel data structs. | -- what's the point of some daemons assuring the outer process doesn't exit | before the innermost actually runs? Depends upon the needs of the processes. Some creating processes want to make sure it works, and try again if there was a failure. In other cases timing matters, want to avoid going to the next step (whatever that is) before the daemon is ready to work. In others it just doesn't matter. | And: | -- is there a way to detach in a shell script? Not that I am aware of. Most of it you can do, but not the setsid(). kre