pgid of spawned processes

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

pgid of spawned processes

Jonathan Leonard
Hi,

Is it possible to get make to pass on its process group id to any children
processes it spawns?

[Please 'reply all' as I am not subscribed to this group].

Thanks!
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: pgid of spawned processes

Rakesh Sharma-6
The environment is passed on to it's child processes by make, so if you can find a way to push the pid of your make run into one then you're done.


a) Invoke make as follows:

tmpf=`mktemp`

TMPF="$tmpf" make -f yourmakefile yourtarget &

pid=$!

echo "$pid" > $tmpf

wait "$pid"

rm -f "$tmpf"


b) Inside yourmakefile:

export MAKE_PID := $(shell while [  !  -s "$(TMPF)"  ]; do :; done; cat < $(TMPF))


###

Now all child(s) of this make shall inherit the env $(MAKE_PID)


--Rakesh


________________________________
From: Help-make <help-make-bounces+sharma__r=[hidden email]> on behalf of Jonathan Leonard <[hidden email]>
Sent: Saturday, November 5, 2016 2:11 PM
To: [hidden email]
Subject: pgid of spawned processes

Hi,

Is it possible to get make to pass on its process group id to any children
processes it spawns?

[Please 'reply all' as I am not subscribed to this group].

Thanks!
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Help-make -- Users list for the GNU implementation of make<https://lists.gnu.org/mailman/listinfo/help-make>
lists.gnu.org
Help-make -- Users list for the GNU implementation of make About Help-make



_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: pgid of spawned processes

Jonathan Leonard
Thanks for the nudge in the right direction but...

... an easier way to make that happen is to introduce an initial bash
script:

#!/bin/bash
export ROOT_PID=$$
make -f yourmakefile yourtarget

[This will set the bash script's PID into the env of all descendants (which
is good enough for our purposes here as the make process itself needn't be
the actual root)].

--Jonathan


On Sun, Nov 6, 2016 at 7:23 AM, Rakesh Sharma <[hidden email]> wrote:

> The environment is passed on to it's child processes by make, so if you
> can find a way to push the pid of your make run into one then you're done.
>
>
> a) Invoke make as follows:
>
> tmpf=`mktemp`
>
> TMPF="$tmpf" make -f yourmakefile yourtarget &
>
> pid=$!
>
> echo "$pid" > $tmpf
>
> wait "$pid"
>
> rm -f "$tmpf"
>
>
> b) Inside yourmakefile:
>
> export MAKE_PID := $(shell while [  !  -s "$(TMPF)"  ]; do :; done; cat <
> $(TMPF))
>
>
> ###
>
> Now all child(s) of this make shall inherit the env $(MAKE_PID)
>
>
> --Rakesh
>
>
> ------------------------------
> *From:* Help-make <help-make-bounces+sharma__r=[hidden email]> on
> behalf of Jonathan Leonard <[hidden email]>
> *Sent:* Saturday, November 5, 2016 2:11 PM
> *To:* [hidden email]
> *Subject:* pgid of spawned processes
>
> Hi,
>
> Is it possible to get make to pass on its process group id to any children
> processes it spawns?
>
> [Please 'reply all' as I am not subscribed to this group].
>
> Thanks!
> _______________________________________________
> Help-make mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-make
> Help-make -- Users list for the GNU implementation of make
> <https://lists.gnu.org/mailman/listinfo/help-make>
> lists.gnu.org
> Help-make -- Users list for the GNU implementation of make About Help-make
>
>
>
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: pgid of spawned processes

Rakesh Sharma-6
You may want to restrict the extent of the env to the make (+ it's children) rather than the whole bash script, with the following:


              ROOT_PID="$$"    make  -f    yourmakefile    yourtarget


--Rakesh


________________________________
From: Jonathan Leonard <[hidden email]>
Sent: Sunday, November 6, 2016 2:27 PM
To: Rakesh Sharma
Cc: [hidden email]
Subject: Re: pgid of spawned processes

Thanks for the nudge in the right direction but...

... an easier way to make that happen is to introduce an initial bash script:

#!/bin/bash
export ROOT_PID=$$
make -f yourmakefile yourtarget

[This will set the bash script's PID into the env of all descendants (which is good enough for our purposes here as the make process itself needn't be the actual root)].

--Jonathan


On Sun, Nov 6, 2016 at 7:23 AM, Rakesh Sharma <[hidden email]<mailto:[hidden email]>> wrote:

The environment is passed on to it's child processes by make, so if you can find a way to push the pid of your make run into one then you're done.


a) Invoke make as follows:

tmpf=`mktemp`

TMPF="$tmpf" make -f yourmakefile yourtarget &

pid=$!

echo "$pid" > $tmpf

wait "$pid"

rm -f "$tmpf"


b) Inside yourmakefile:

export MAKE_PID := $(shell while [  !  -s "$(TMPF)"  ]; do :; done; cat < $(TMPF))


###

Now all child(s) of this make shall inherit the env $(MAKE_PID)


--Rakesh


________________________________
From: Help-make <help-make-bounces+sharma__r=[hidden email]<mailto:[hidden email]>> on behalf of Jonathan Leonard <[hidden email]<mailto:[hidden email]>>
Sent: Saturday, November 5, 2016 2:11 PM
To: [hidden email]<mailto:[hidden email]>
Subject: pgid of spawned processes

Hi,

Is it possible to get make to pass on its process group id to any children
processes it spawns?

[Please 'reply all' as I am not subscribed to this group].

Thanks!
_______________________________________________
Help-make mailing list
[hidden email]<mailto:[hidden email]>
https://lists.gnu.org/mailman/listinfo/help-make
Help-make -- Users list for the GNU implementation of make<https://lists.gnu.org/mailman/listinfo/help-make>
lists.gnu.org<http://lists.gnu.org>
Help-make -- Users list for the GNU implementation of make About Help-make




_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make