bug-parallel
[Top][All Lists]
Advanced

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

Parallel cannot determine the shell on arm64 macs running emulated linux


From: Andrew Achkar
Subject: Parallel cannot determine the shell on arm64 macs running emulated linux/amd64 docker containers
Date: Fri, 1 Mar 2024 12:43:24 -0500

Hi, 

I believe I found a bug relating to how parallel determines the parent shell when running under emulated docker containers on mac.

To reproduce this bug, run the following steps on an apple mac using M series arm64 chips using Docker Desktop for Mac (4.27.2).

# important to run emulated
docker run --rm -it --platform linux/amd64 alpine
# install bash and parallel
apk add bash parallel
# start bash shell
bash
# show the default shell
echo $SHELL
/bin/ash
# show the parallel version
parallel --version
GNU parallel 20231122
# define a function
doit() { echo "$@"; }
# export it (bashism)
export -f doit
# run parallel with it
parallel --will-cite doit ::: 1 2
/bin/sh: doit: not found
/bin/sh: doit: not found

# overriding SHELL or PARALLEL_SHELL fixes it:
SHELL=/bin/bash parallel --will-cite doit ::: 1 2
1
2
PARALLEL_SHELL=/bin/bash parallel --will-cite doit ::: 1 2
1
2

I believe this is because the way that parallel determines the parent shell doesn't account for rosetta https://git.savannah.gnu.org/cgit/parallel.git/tree/src/parallel#n6718

# reformatted output to insert \0
cat /proc/$$/cmdline
/run/rosetta/rosetta\0/bin/bash\0bash

 ps
PID   USER     TIME  COMMAND
    1 root      0:00 {sh} /run/rosetta/rosetta /bin/sh /bin/sh
   48 root      0:00 {bash} /run/rosetta/rosetta /bin/bash bash
  877 root      0:00 /bin/ps ps

The leading /run/rosetta/rosetta is not accounted for in the regexp used to determine the parent shell, so the determination fails and falls back to the default of /bin/sh

This was discovered in the course of debugging an issue with running super-linter docker images under emulation, for reference: https://github.com/super-linter/super-linter/issues/5339

Thanks,
Andrew

reply via email to

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