Re: Cleaning up background processes

Liste des Groupes 
Sujet : Re: Cleaning up background processes
De : gazelle (at) *nospam* shell.xmission.com (Kenny McCormack)
Groupes : comp.unix.shell
Date : 06. May 2024, 13:08:39
Autres entêtes
Organisation : The official candy of the new Millennium
Message-ID : <v1ah87$l0a8$1@news.xmission.com>
References : 1 2
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <20240505214609.114@kylheku.com>,
Kaz Kylheku  <643-408-1753@kylheku.com> wrote:
On 2024-05-05, Christian Weisgerber <naddy@mips.inka.de> wrote:
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.
>
Maybe have an EXIT trap which calls wait?

The fundamental underlying problem here is that the EXIT trap is only
called on a "normal" exit.  In particular, it does not get called under (at
least) the following circumstances:

    1) User hits ^C causing the script to abort.

    2) Script exits via an "exec" statement.

As I read it, that's what this thread is actually about.

This is a problem I've often grappled with and I'm convinced that there is
no universal solution.

Having said that, I think we are all making our own assumptions about what
the actual, underlying problem is.  Given that OP is not a newbie, it would
help a lot if he would clarify what exact situation he is dealing with,
rather than have us all guess (which is SOP when the poster *is* a newbie).

--
Indeed, most .NET developers couldn't pass CS101 at a third-rate
community college.
- F. Russell -

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