Compare commits

..

2 Commits

Author SHA1 Message Date
Lily Tsuru 0a0ab0703a Make Process do prctl(PR_SET_PDEATHSIG)
This means that nanosm managed process will also predictably die if nanosm is killed.
2024-02-02 20:38:10 -05:00
Lily Tsuru bc530fe8a2 README/configuration improvements 2024-02-02 20:38:10 -05:00
2 changed files with 12 additions and 2 deletions

View File

@ -6,9 +6,9 @@ Written in C++20, using epoll (without helper libraries), to stay nice and smol
# Why write this?
Because `app &` then `exec wm` is impressively awful. What if your WM crashes, or your panel? Guess you lose them!
Because `app &` then `exec wm` in `.xinitrc` is impressively awful. What if your WM crashes, or your panel? Guess you lose them!
And if your WM crashes? Your whole xorg server goes with it, meaning so does everything else.
And if your WM crashes? Your whole Xorg server goes with it, meaning so does everything else.
A more robust solution that's still small and easy to setup (read: Not written in bash) is clearly a better idea.
@ -28,4 +28,7 @@ $ ninja -C build
# Configuration
- Copy `/usr/share/doc/nanosm/nanosm.toml` to `~/.config/nanosm/` and edit it to your liking/setup.
- Remove the applications you added to your `nanosm.toml` from your `.xinitrc`, since nanosm will handle them
- Add `exec nanosm` to the end of your `.xinitrc`.
- ...
- Profit?

View File

@ -3,6 +3,7 @@
#include <linux/sched.h>
#include <sched.h>
#include <signal.h>
#include <sys/prctl.h>
#include <sys/types.h>
#include "WordExp.hpp"
@ -49,6 +50,12 @@ namespace nanosm {
for(usize i = 0; i < exp.words.size(); ++i)
argv[i] = exp.words[i].data();
// Ensure that if nanosm (the parent) dies, we die along with it
if(prctl(PR_SET_PDEATHSIG, SIGTERM) == -1) {
perror("Process pre-exec: prctl(PR_SET_PDEATHSIG)");
exit(1);
}
exit(execvp(exp.words[0].data(), argv.data()));
} else {
// Parent: monitor the pidfd by adding ourselves to the event loop now