Comments (11)
So it might be because of the terminal, or it might be caused by bash.
I'm going to investigate it tomorrow.
from nwg-drawer.
Took a look at golang docs and at the launch function of nwg-drawer.
The fix might be really easy, actually:
the cmd object provided by os/exec contains the lower level Process object as per golang docs.
A Process object should be detached upon calling Release on it, so cmd.Process.Release() should do the trick.
Don't take my word for granted though, I'm just at the beginning with golang.
from nwg-drawer.
I'm just at the beginning with golang
LOL, so am I. Thanks for looking into it. Possibly I'll be able to push forward this, and some more pending tasks in next few days.
from nwg-drawer.
No problem!
Anyway, I managed to make it work, but I needed to include "sys" and add the setsid attribute to the child process.
cmd.Process.Release() didn't seem to impact the spawned program in any way.
cmd.SysProcAttr = &syscall.SysProcAttr {
Setsid: true,
}
cmd.Start()
This way, the child process isn't killed when the launcher is killed with SIGKILL.
As far as I know, this shouldn't prevent the program to be used on BSD if it previously worked, but I can't test right now.
I'm still searching a solution for the zombie processes.
edit: updated my fork, see nightly-brew@b78092c.
from nwg-drawer.
edit: updated my fork, see nightly-brew/nwg-drawer@b78092c
This could be applied, but to be honest I can't reproduce the issue on my machine. If I start some apps from the resident drawer instance, and then kill the drawer, the apps are still alive. As expected when you use cmd.Start()
.
from nwg-drawer.
Interesting. You are right, but I still manage to reproduce the issue.
After testing some more though the behaviour seems to be weirdier than I was expecting and I'm starting to doubt if this is an issue with my setup, my knowledge of the system or something else.
Would you mind if I explained what I did?
I'm running archlinux on an x86_64 computer.
I tested this with keepassxc, gnome clocks and gnome calendar, all of them at the latest release.
To launch the resident instance I opened a kitty-terminal window, with bash as a shell, and promptly typed "nwg-drawer -r".
I opened another kitty window on the right with htop, to track the process tree.
- If I open one of the mentioned programs, then send a signal with htop to the resident instance, the program is reparented correctly. I tried SIGKILL, SIGQUIT and SIGINT, no issue here.
- The same can be said if I terminate the drawer by using killall -9 nwg-drawer (the number varies per signal).
- If I ctrl+c the drawer in the kitty window though, the child processes are all killed.
What baffles me is the fact that ctrl+c is the same as sending SIGINT.
Am I missing something?
from nwg-drawer.
I launch the resident instance of the drawer from the sway config, like exec nwg-drawer -r
. Possibly this makes the difference.
from nwg-drawer.
Found out what was happening.
Shells like bash, sh and so on handle started processes as jobs. Each one of the jobs can start other sub-processes to carry on their work.
The caller process and its spawns are put in what is called a process group. The process group is identified by the group's leader.
When pressing ctrl+c in bash, a SIGINT is sent to the entire process group of the foreground job, not only to its leader.
The difference is that htop and kill do not normally send the signal to the process group, but to the specified pid.
Well... I was sending SIGINT only to nwg-drawer, not to the spawned processes.
I verified that the behaviour becomes consistent if I use kill with a 'minus' in front of nwg-drawer's pid, as it sends the signal to the entire group.
What my fix did was effectively separate the spawned processes from the drawer's group process, preventing SIGINT and any other signal intended for the drawer's process group from reaching them.
from nwg-drawer.
What my fix did was (...)
If you think it should be added, feel free to PR.
from nwg-drawer.
I hope I'm not introducing any hassle with this PR, it would be a bummer.
from nwg-drawer.
Thanks!
from nwg-drawer.
Related Issues (20)
- Dead icons in nwg-drawer HOT 5
- Dotted lines not in drawer.css HOT 3
- nwg-drawer send string to search from command line HOT 5
- Can't click on waybar when nwg-drawer is open HOT 3
- Categories not showing HOT 14
- [CHANGED BEHAVIOR] New installation opens default list differently, can't fix HOT 6
- Uninstalled apps impossible to unpin HOT 1
- Drawer not following CSS with newest update HOT 2
- New option --config HOT 1
- /tmp/nwg-drawer.lock was owned by other user HOT 1
- nwg-drawer upgrade from 0.2.8 to 0.3.0 broke HOT 1
- Non-ascii character problem in menu name shortening HOT 6
- Specify icon theme HOT 7
- Panic when run pkill -USR1 nwg-drawer HOT 6
- Launching thunar from nwg-drawer opens in sway config directory HOT 2
- feature: prefer most used applications HOT 1
- Add CI HOT 2
- Launching certain apps HOT 10
- Change term overriding variable and improve error handling? HOT 4
- Some icons appear smaller and are offset when searching HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nwg-drawer.