[yocto] [PATCH 2/2] Kill suprocesses when pressing ctrl+c
Paul Eggleton
paul.eggleton at linux.intel.com
Thu Aug 21 05:41:12 PDT 2014
Hi Marius,
On Thursday 21 August 2014 15:00:31 Marius Avram wrote:
> This way the created bitbake subprocesses from the upgrade script
> are killed as well when you press ctrl+c.
>
> Signed-off-by: Marius Avram <marius.avram at intel.com>
> ---
> upgradehelper.py | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/upgradehelper.py b/upgradehelper.py
> index 771c981..7db89a7 100755
> --- a/upgradehelper.py
> +++ b/upgradehelper.py
> @@ -35,6 +35,7 @@ from logging import warning as W
> from logging import error as E
> from logging import critical as C
> import re
> +import signal
> import sys
> import ConfigParser as cp
> from datetime import datetime
> @@ -645,11 +646,16 @@ class UniverseUpdater(Updater):
> self.prepare()
> super(UniverseUpdater, self).run()
>
> +def close_child_processes(signal_id, frame):
> + pid = os.getpid()
> + os.killpg(pid, signal.SIGKILL)
I could be wrong but I think this ought to be:
pgid = os.getpgrp()
os.killpg(pgid, signal.SIGKILL)
>
> if __name__ == "__main__":
> global settings
> global maintainer_override
>
> + signal.signal(signal.SIGINT, close_child_processes)
> +
> debug_levels = [log.CRITICAL, log.ERROR, log.WARNING, log.INFO,
> log.DEBUG] args = parse_cmdline()
> log.basicConfig(format='%(levelname)s:%(message)s',
--
Paul Eggleton
Intel Open Source Technology Centre
More information about the yocto
mailing list