deadpixi / sam

An updated version of the sam text editor.
Other
436 stars 47 forks source link

Don't remove socket when exiting forked process #130

Open vtrlx opened 5 months ago

vtrlx commented 5 months ago

Previously, using any command that forked sam would run the odd risk of causing sam's control socket to exit. This seems to be a consequence of using atexit() to schedule removal of the control socket from the file system.

This commit adds a global boolean named forked, which is set to true in child process after they are forked. The exit handlers removesocket() and rmsocket() are changed such that they don't remove the control sockets if the forked boolean is set to true.

Sam's control socket should only get removed once the main instance exits.

Fixes #75