bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

FEATURE REQUEST : shell option to automatically terminate child processe


From: Corto Beau
Subject: FEATURE REQUEST : shell option to automatically terminate child processes on parent death
Date: Sat, 11 Nov 2023 14:08:40 +0100
User-agent: Mozilla Thunderbird

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2
uname output: Linux zinc 6.6.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 08 Nov 2023 16:05:38 +0000 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2 Patch
Level: 21
Release Status: release

Description:
Hi,

I would like to suggest a new shell option to ensure child processes are automatically killed when the parent dies.

Right now, it's already possible to emulate this feature by setting a trap to kill all child processes on exit (trap "kill 0" EXIT), but obviously it doesn't work if the process is terminated by a signal that cannot be caught (like SIGKILL).

On Linux, it can be done by setting the PR_SET_PDEATHSIG flag to propagate the parent termination signal to the child, regardless of whether the signal can be caught or not.

The rationale for this feature is that scripts spawning background processes to listen to various events (udev events, window manager events, etc) often leave orphan processes behind when terminated forcefully.

I've attached a proof-of-concept patch.

Attachment: no_reparent.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]