Skip to content

Instantly share code, notes, and snippets.

@x-yuri
Last active February 13, 2021 03:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x-yuri/09b67a6db0903dc3a562747d2c242031 to your computer and use it in GitHub Desktop.
Save x-yuri/09b67a6db0903dc3a562747d2c242031 to your computer and use it in GitHub Desktop.
#dcron #docker #alpine #eperm

dcron: setpgid: Operation not permitted

a.sh:

#!/bin/sh -eu
docker run --rm -v $PWD/b.sh:/b.sh alpine ./b.sh

b.sh:

#!/bin/sh -eux
apk add dcron procps
ps -eHo sess,pgrp,ppid,pid,comm,args
exec crond -df
:r!./a.sh
...
+ ps -eHo sess,pgrp,ppid,pid,comm,args
   SESS    PGRP    PPID     PID COMMAND         COMMAND
      1       1       0       1 b.sh            /bin/sh -eux ./b.sh
      1       1       1      10   ps              ps -eHo sess,pgrp,ppid,pid,comm,args
+ exec crond -df
setpgid: Operation not permitted

Without exec it succeeds. Apparently it happens because dcron calls setpgid(), but with exec it's the session leader.

EPERM An attempt was made [...] to change the process group ID of a session leader (setpgid(), setpgrp()).

https://man.archlinux.org/man/core/man-pages/setpgid.2.en#ERRORS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment