[Top][All Lists]

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

Re: bash: please provide an easy way to spawn a new process group from s

From: clime
Subject: Re: bash: please provide an easy way to spawn a new process group from script
Date: Sun, 1 Nov 2020 11:13:37 +0100

On Sun, 1 Nov 2020 at 11:01, Oğuz <oguzismailuysal@gmail.com> wrote:
> 1 Kasım 2020 Pazar tarihinde clime <clime7@gmail.com> yazdı:
> ...
>> Please, provide a syntactic construct to spawn a new process group (or
>> at least there should be some usable command to do that).
> You can use the loadable builtin `setpgid' if you have to. Assuming 
> BASH_LOADABLES_BUILTIN is set, this should work:
>     enable -f setpgid{,}
>     { setpgid $BASHPID{,}; a | b; } &
>     setpgid $!{,}
>     kill -- -$!

Hello, it doesn't work for me:

$ enable -f setpgid{,}
bash: enable: cannot open shared object setpgid: setpgid: cannot open
shared object file: No such file or directory

Also it looks quite complex. Why isn't there a simple (already
enabled) builtin e.g. like:

newpgid { a | b; } & pid=$!

where pid for `{ a | b; } &` will be stored in pid and will be also
the new gpid of the spawned process group.

Work with process groups should be natural in bash. It can't be that
complex. I struggled with this for several hours and found lots of
people on the net that struggled with the same problem too.

(in the end, i needed to do a helper function which uses ps to
recursively collect children of that process and then i passed all
those children to kill which is probably valid but one would expect
bash can do this in a better way and this really delayed my work).

Thank you very much

>> Thank you
>> clime
> --
> Oğuz

reply via email to

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