tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: RUN_PRECMD hook
On Sun, 12 Apr 2026 at 15:01, Jonathan Perkin <jperkin%pkgsrc.org@localhost> wrote:
>
> One final part of my bulk build migration is support for cputime limits
> to stop spinning processes from hanging builds indefinitely. In pbulk I
> simply had this line in pbulk.conf:
>
> ulimit -S -t 3600
>
> which then applied to all child build scripts. I was about to add a new
> feature to bob to support arbitrary precmds, but on reflection felt that
> this would actually be better as a native pkgsrc feature so that it
> works everywhere and not just in bulk builds.
>
> My initial draft is to add a RUN_PRECMD hook to ${RUN}, so that I can
> set e.g.
>
> RUN_PRECMD= ulimit -S -t 3600
>
> in mk.conf and everything should Just Work.
>
> --- a/mk/misc/common.mk
> +++ b/mk/misc/common.mk
> @@ -10,0 +11,5 @@
> +# RUN_PRECMD
> +# Commands that are placed at the end of the expanded ${RUN} and before
> +# the main body of commands. This is a helpful place to insert e.g.
> +# 'ulimit' to avoid hung processes causing builds to run indefinitely.
> +#
> @@ -30,0 +36 @@ PKG_DEBUG_LEVEL?= 0
> +RUN_PRECMD?= :
> @@ -44 +50 @@ _PKG_DEBUG_SCRIPT= ${SH} -x
> -RUN= ${_PKG_SILENT}${_PKG_DEBUG} set -e;
> +RUN= ${_PKG_SILENT}${_PKG_DEBUG} set -e; ${RUN_PRECMD};
>
> Any better ideas? Would a more specific LIMIT_RESOURCES feature that is
> analogous to UNLIMIT_RESOURCES be more appropriate, or just too complex?
I like the flexibility of RUN_PRECMD. Maybe just expand the comment a
little to give a casual reader more guidance?
+# the main body of commands. This is a helpful place to insert e.g.
+# 'ulimit -S -t 3600' to abort after 3600 seconds to avoid hung processes
+# causing builds to run indefinitely.
David
Home |
Main Index |
Thread Index |
Old Index