Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
https://wiki.archlinux.org/title/Bug_reporting_guidelines
Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.
REPEAT: Do NOT report bugs for outdated packages!
FS#38665 - [arch-install-scripts] killing pacstrap still lets the underlying pacman subprocess alive
Attached to Project:
Arch Linux
Opened by Francis Moreau (fmoreau) - Sunday, 26 January 2014, 11:27 GMT
Last edited by Dave Reisner (falconindy) - Friday, 07 February 2014, 14:50 GMT
Opened by Francis Moreau (fmoreau) - Sunday, 26 January 2014, 11:27 GMT
Last edited by Dave Reisner (falconindy) - Friday, 07 February 2014, 14:50 GMT
|
DetailsDescription: after starting pacstrap to initialize a new chroot, I tried to kill it for some reasons. But although the pacstrap process is gone, the pacman subprocess (started by pacstrap) is still running.
Additional info: * package version(s) arch-install-scripts 12-1 pacman 4.1.2-5 Steps to reproduce: $ pacstrap /mnt base ... $ pkill pacstrap $ ps aux | grep pacman root 1241 5.5 0.0 153416 15112 pts/2 S 12:21 0:01 pacman -r /mnt -Sy base --cachedir=/mnt/var/cache/pacman/pkg --noconfirm $ pkill pacman $ ps aux | grep pacman $ |
This task depends upon
Closed by Dave Reisner (falconindy)
Friday, 07 February 2014, 14:50 GMT
Reason for closing: Won't implement
Additional comments about closing: This doesn't make sense to include as part of pacstrap since it's an interactive script and already properly handles SIGINT, as interactive scripts do. it makes no sense to treat pacstrap as a daemon and handle such signals as SIGTERM.
Friday, 07 February 2014, 14:50 GMT
Reason for closing: Won't implement
Additional comments about closing: This doesn't make sense to include as part of pacstrap since it's an interactive script and already properly handles SIGINT, as interactive scripts do. it makes no sense to treat pacstrap as a daemon and handle such signals as SIGTERM.
Probably SIGHUP signal is blocked by pacman, but I don't think it's a good idea to let pacman still running if its parent is killed.
SIGINT is blocked during install and caught during downloads. I don't recall anything in pacstrap that would prevent the usual propagation of signals to child processes....
I was just thinking that pacman is indeed blocking a signal (was thinking about SIGHUP) which prevents it to exit if its parent died.
Just try it, try to send SIGTERM to pacman and see what's happening and tell me if you think it's a correct behaviour.
If you think so, please explain.
Thanks.
Right, I just pointing out the disparity between your initial report and followup (which I guess I slightly misread while on the train).
I don't even understand what would cause you to perform this sequence of actions, but it's the default behavior of bash. You can do something as simple as:
#!/bin/bash
sleep 100
Name this script whatever, run it, kill the script, and the sleep process will remain. The point is that you're sending TERM to a specific process, not the process group. The *only* case where bash will clean up after itself is if you send a signal to the jobspec of a backgrounded job from the same shell (e.g. ./foo & kill %1).
I really have to wonder if this isn't something that you, the user, need to fix. pkill has a -g flag which probably does what you want.
I'm not sure to understand why you took bash as an example. It surely handles signals in its own way but my question was about pacstrap.
> Right, I just pointing out the disparity between your initial report and followup (which I guess I slightly misread while on the train).
which disparity ?
I'm sorry if my question was unclear, so let try one more time: as a user point of view, I find odd that when killing pacstrap (pkill pacstrap), there's still a background process (pacman) that's still initializing a directory and thus preventing any operations on that directory such as unmounting it, cleaning it etc...
Maybe it's more a pacman behaviour: if its parent process exits before it finishes, isn't this a hint that it should stop its job ?
Thanks
It's not an example, it's what's relevant here because pacstrap IS a bash script. Your bug report has everything to do with the default signal handling behavior of bash, which I previously explained.
> I find odd that when killing pacstrap (pkill pacstrap),
And again, this is what I find confusing. What situation are you finding yourself in that you're sending pkill to pacstrap and not just interrupting the process with ^C?
> Maybe it's more a pacman behaviour: if its parent process exits before it finishes, isn't this a hint that it should stop its job ?
This doesn't even make sense -- pacman has nothing to do with this. Replace the "pacman" command in pacstrap with "sleep 100" and you'll see the exact same behavior.
You keep using the "sleep 100" example. But leaving a background sleep is not really the same that a background process doing heavy IOs.
Really, what is your use case?
Install your own signal handler to kill the process group if you really think that you need this.
def on_sigterm(signum, unused_frame):
signal.signal(signum, signal.SIG_DFL)
os.kill(-os.getpid(), signum)
signal.signal(signal.SIGTERM, on_sigterm)