According to Bash: Special Parameters:
($!) Expands to the process ID of the job most recently placed into the background, whether executed as an asynchronous command or using the bg builtin
I can utilize this as follows:
$ leafpad &
[2] 3962
$ kill $!
This works and kills the most recent process (eg. leafpad) but for notify-send it seems not working:
$ notify-send Hello &
[2] 4052
$ kill $!
bash: kill: (4052) - No such process
And I have to use killall notify-osd in order to kill it.
So, I want to know why kill $! doesn't work for notify-send? And what is the proper way to kill such a process?
Note: I know that I can specify the time-out, but this is a different issue.
In short, notify-send is part of
– forgotstackxpassword Apr 02 '16 at 15:05notify-osd, and is not running by the time you kill it, and also is supposed to only run as "notify-osd" according to NotifyOSD developer Design Specificationsnotify-send Hello &and thekill $!. On hitting Enter, the shell should display something like[1]+ Done notify-send Helloindicating that the job has terminated. – cas Apr 02 '16 at 22:37