[jhalfs] 02/02: Fix (again) the run-in-cgroup.sh script

"Git Owner" ([email protected] via alfs-discuss Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.automated
Message-ID <[email protected]>
This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch xry111/parallelism
in repository jhalfs.

commit 249d4ade208ff645ee5d5d409a4dba6f08561fa4
Author: Pierre Labastie <[email protected]>
AuthorDate: Thu Nov 16 16:10:46 2023 +0100

    Fix (again) the run-in-cgroup.sh script
    
    When using "sh  << EOF", what is between this line and EOF runs
    with no attached terminal. But we need a terminal for running the
    build. So we have to use "sh -c ". But then nesting of double
    quotes, $, etc is too complicated. So run as root, and become back
    user only when exec'ing. For some reason $@ does not work, so use
    a variable set to $@.
---
 common/run-in-cgroup.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/common/run-in-cgroup.sh b/common/run-in-cgroup.sh
index 8794cd4..3f57857 100755
--- a/common/run-in-cgroup.sh
+++ b/common/run-in-cgroup.sh
@@ -5,6 +5,8 @@ if [ -z "$CPUSPEC" ] || [ "$#" -lt 1 ]; then
 	exit 1
 fi
 
+ARGS="$@"
+
 set +e
 
 if type systemd-run >/dev/null 2>&1 ; then # systemd
@@ -17,12 +19,11 @@ elif type loginctl >/dev/null 2>&1 ; then #elogind
    sudo sh -c "echo +cpuset > /sys/fs/cgroup/cgroup.subtree_control"
    (
       sudo sh -c "echo $BASHPID > /sys/fs/cgroup/jhalfs/cgroup.procs"
-      sudo -u $(whoami) sh <<EOF
+      sudo sh -c "
          SESS_CGROUP=/sys/fs/cgroup/\$XDG_SESSION_ID
-         sudo sh -c "echo \\"$CPUSPEC\\" > \$SESS_CGROUP/cpuset.cpus"
-         (sudo sh -c "echo \$BASHPID > \$SESS_CGROUP/cgroup.procs" &&
-            exec $@)
-EOF
+         echo $CPUSPEC > \$SESS_CGROUP/cpuset.cpus
+	 ( echo \$BASHPID > \$SESS_CGROUP/cgroup.procs &&
+		 exec sudo -u $(whoami) $ARGS )"
    )
    sudo rmdir /sys/fs/cgroup/jhalfs
 else # no session manager

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

-- 
http://lists.linuxfromscratch.org/sympa/info/alfs-discuss
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.