Cleaning up background processes

Liste des GroupesRevenir à cu shell 
Sujet : Cleaning up background processes
De : naddy (at) *nospam* mips.inka.de (Christian Weisgerber)
Groupes : comp.unix.shell
Date : 05. May 2024, 21:06:22
Autres entêtes
Message-ID : <slrnv3fm5e.jrj.naddy@lorvorc.mips.inka.de>
User-Agent : slrn/1.0.3 (FreeBSD)
Is there a standard POSIX shell idiom to clean up background
processes?

You have a shell script that starts some background process with &.
Now you want to make sure that the background process terminates
when the shell script terminates.  In particular, when it terminates
due to special circumstances.

A noninteractive shell doesn't use job control, so the background
process shares the same process group.  That's great!  When somebody
hits ^C, SIGINT is sent to the whole process group.  The same for
^\ and SIGQUIT, and for SIGHUP when the modem hangs up^W^W^Wxterm
is closed.  So the background process will be terminated by default.

Except... bash seems to block SIGINT for background processes.  As
does FreeBSD's sh with both SIGINT and SIGQUIT.  What now?

Also, the shell script is typically invoked from some implementation
of make(1), which seems to add more complications.

This seems like a sufficiently common problem that there must be a
standard solution.

--
Christian "naddy" Weisgerber                          naddy@mips.inka.de

Date Sujet#  Auteur
5 May 24 * Cleaning up background processes17Christian Weisgerber
5 May 24 +- Re: Cleaning up background processes1Lawrence D'Oliveiro
5 May 24 +- Re: Cleaning up background processes1Christian Weisgerber
6 May 24 +- Re: Cleaning up background processes1vallor
6 May 24 `* Re: Cleaning up background processes13Kaz Kylheku
6 May 24  `* Re: Cleaning up background processes12Kenny McCormack
8 May 24   +* Re: Cleaning up background processes9vallor
9 May 24   i+* Re: Cleaning up background processes4Janis Papanagnou
10 May 24   ii`* Re: Cleaning up background processes3Geoff Clare
10 May 24   ii `* Re: Cleaning up background processes2Janis Papanagnou
19 May 24   ii  `- Re: Cleaning up background processes1Martijn Dekker
11 May 24   i`* Re: Cleaning up background processes4Christian Weisgerber
11 May 24   i `* Re: Cleaning up background processes3Kenny McCormack
12 May 24   i  `* Re: Cleaning up background processes2Christian Weisgerber
13 May 24   i   `- Re: Cleaning up background processes1Geoff Clare
11 May 24   `* Re: Cleaning up background processes2Christian Weisgerber
11 May 24    `- Re: Cleaning up background processes1Kenny McCormack

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal