2

My actual problem is that a process I run in an rcfile in docker as docker run container bash --rcfile rcfile remains attached to the bash session by sharing the PGID which means that when I Ctrl-C an unrelated command the process receives a SIGINT

So, inside the rcfile its just (nohup command &), when instead of using the rcfile I call it directly in the shell the PGID is different and Ctrl-C does not affect.

From there I deduced that for some reason, bash does not background processes the same while executing the rcfile.

Wrote a small test without docker where I see the PGID behavior.

RCFILE, sleep and bash share PGID

Cobain ~/tmp/testbash$ cat rcfile 
#!/bin/bash
(sleep 10 &)

Cobain ~/tmp/testbash$ bash --rcfile rcfile
arkaitzj@Cobain:~/tmp/testbash$ ps -o  "%p %r %y %x %c"
  PID  PGID TTY          TIME COMMAND
 2883  2883 pts/0    00:00:06 bash
27911 27911 pts/0    00:00:00 bash
27913 27911 pts/0    00:00:00 sleep
27914 27914 pts/0    00:00:00 ps

Command input in the shell, PGID differs

Cobain ~/tmp/testbash$ bash
Cobain ~/tmp/testbash$ ( sleep 10 &)
Cobain ~/tmp/testbash$  ps -o  "%p %r %y %x %c"
  PID  PGID TTY          TIME COMMAND
 2883  2883 pts/0    00:00:06 bash
27999 27999 pts/0    00:00:00 bash
28127 28126 pts/0    00:00:00 sleep
28132 28132 pts/0    00:00:00 ps

What I don't understand of this bash example though, is that in the rcfile case, when I ctrl-C it does not SIGINT the sleep process, when it is sharing the PGID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.