Comments (5)
By all means. You know this stuff better than me! (And add your name to the header info, since you have contributed a lot to the script ;) )
from bunsen-utilities.
@johnraff Why is SIGKILL necessary? Does the program ignore SIGTERM? If need be, send SIGTERM, wait, check again and then send SIGKILL.
from bunsen-utilities.
SIGKILL should not be necessary, but the tint2 version in Jessie seems to have a freezing bug, and when it occurs SIGKILL is the only signal that will kill it.
http://crunchbang.org/forums/viewtopic.php?pid=430787#p430787
Yes the script could be enhanced to try SIGTERM first. It's a bit of extra code, but I'll try it today.
In fact, the script could fairly easily be expanded to take any process name as argument to make it a generic bl-restart for possible use elsewhere. It would mean either modifying the call in bl-tint2-pipemenu or making a wrapper script bl-tint2-restart which called bl-restart tint2
.
from bunsen-utilities.
@2ion I guess a 0.5s wait before using SIGKILL should be enough?
something like:
declare -A commands # associative array
while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill "$pid"
sleep 0.5
kill -0 "$pid" && kill -KILL "$pid"
commands[$cmd]=1 # duplicate commands will be launched only once
fi
done <<< "$(pgrep -a tint2)"
Although really I'm not sure if there's any meaning in testing with kill -0 in kill -0 "$pid" && kill -KILL "$pid"
.
Just kill -KILL "$pid" >/dev/null 2>&1
after the sleep would be enough, no?
from bunsen-utilities.
I've thought some more, and there's a possible race condition with the above code. During the sleep 0.5
it's possible, even if unlikely, that another process would start with the same $pid that the killed tint2 process had. That innocent process would then be killed.
It can be avoided by re-running the loop using the output of pgrep -a tint2
. Thus:
#!/bin/bash
#
# bl-tint2restart to be used by bl-tint2-pipemenu
# Written for BunsenLabs Linux by <damo> June 2015
# and <johnraff> July 2015
declare -A commands # associative array
while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill "$pid"
commands[$cmd]=1 # duplicate commands will be launched only once
fi
done <<< "$(pgrep -a tint2)"
sleep 1
# any processes still running will be killed with SIGKILL
while read pid cmd; do
if [[ ${cmd%% *} = tint2 ]]; then
kill -KILL "$pid"
commands[$cmd]=1
fi
done <<< "$(pgrep -a tint2)"
sleep 1
for i in "${!commands[@]}" # go through the indexes
do
(setsid $i &)
sleep 0.1
done
sleep 1
bl-compositor --restart # restart compositor
exit 0
from bunsen-utilities.
Related Issues (20)
- bl-exit --logout fails HOT 5
- bl-exit - typo fixed HOT 1
- bl-exit: remove call to bl-lock with suspend? HOT 4
- Remove package scrot and bunsen-utilities is removed with it. HOT 2
- bl-obthemes: function countMonitors() fails if no primary monitor is set HOT 16
- hotkeys for bl-exit HOT 27
- bl-lock HOT 2
- bl-kb --gui outputs unnecessary text HOT 1
- bl-exit/merlin branch - make icon names consistent HOT 1
- bl-exit/merlin branch - test for icon dimensions HOT 9
- Commits in master should be in deuterium. HOT 5
- bl-exit/merlin: Need test for current monitor HOT 3
- yad scripts (deuterium) don't display help text if run in terminal HOT 4
- bin scripts (deuterium) not executable HOT 3
- bl-obthemes: firefox-esr icon lost when restoring HOT 9
- bl-exitrc [style] dir requires full filepath HOT 3
- bl-kb does not handle Keybinds wih multiple actions HOT 19
- bl-reload-gtk23 error message when reloading running xsettingsd HOT 2
- bl-conky-manager ignores symlinks to conky files HOT 3
- When bl-tint2-session load tint2-sessionfile, empty line launch default tint2rc.
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 bunsen-utilities.