Deutsch English Français Italiano |
<v1gpdq$3me9$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!news.nobody.at!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: vallor <vallor@cultnix.org> Newsgroups: comp.unix.shell Subject: Re: Cleaning up background processes Date: Wed, 8 May 2024 21:04:58 -0000 (UTC) Organization: A noiseless patient Spider Lines: 44 Message-ID: <v1gpdq$3me9$1@dont-email.me> References: <slrnv3fm5e.jrj.naddy@lorvorc.mips.inka.de> <20240505214609.114@kylheku.com> <v1ah87$l0a8$1@news.xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Wed, 08 May 2024 23:04:58 +0200 (CEST) Injection-Info: dont-email.me; posting-host="b4d3f200feaa5642c33106880b90c11a"; logging-data="121289"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2efP8e5U18xgFxaWvET1x" User-Agent: Pan/0.158 (Avdiivka; cf43eb8; Linux-6.8.9) Cancel-Lock: sha1:dyem2ZqdkR0h5e/Ykz781cQdqlY= X-Face: \}2`P"_@pS86<'EM:'b.Ml}8IuMK"pV"?FReF$'c.S%u9<Q#U*4QO)$l81M`{Q/n XL'`91kd%N::LG:=*\35JS0prp\VJN^<s"b#bff@fA7]5lJA.jn,x_d%Md$,{.EZ Bytes: 2851 On Mon, 6 May 2024 12:08:39 -0000 (UTC), gazelle@shell.xmission.com (Kenny McCormack) wrote in <v1ah87$l0a8$1@news.xmission.com>: > 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. I'm sorry, but I've waited and nobody said anything, so I have to ask: Why couldn't you trap "kill -1 0" INT? > 2) Script exits via an "exec" statement. This is true, and I can't see any way around that. > 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). Wish they would clarify what they meant... -- -v