0

When does a command in a process substitution in bash start and finish running? E.g.

  • when does command1 in command2 >(command1) start and finish running respectively?

  • when does command3 in command4 <(command3) start and finish running respectively?

When does a command in a FIFO start and finish running? E.g.

  • when does prog2 in mkfifo fifo1; prog2 < fifo1 &; prog1 > fifo1; start and finish running respectively?
  • when does prog3 in mkfifo fifo2; prog3 > fifo12 &; prog2 < fifo2; start and finish running respectively?

Thanks.

1 Answer 1

1

Experimentally, in bash:

$ strace -tttfe execve bash -c 'sleep 5 <(sleep 6)'
1522025733.188859 execve("/bin/bash", ["bash", "-c", "sleep 5 <(sleep 6)"], [/* 41 vars */]) = 0
strace: Process 24248 attached
[pid 24247] 1522025733.215188 execve("/bin/sleep", ["sleep", "5", "/dev/fd/63"], [/* 41 vars */]) = 0
strace: Process 24249 attached
[pid 24249] 1522025733.218331 execve("/bin/sleep", ["sleep", "6"], [/* 41 vars */]) = 0
sleep: invalid time interval ‘/dev/fd/63’
Try 'sleep --help' for more information.
[pid 24247] 1522025733.227459 +++ exited with 1 +++
[pid 24249] 1522025739.230933 +++ exited with 0 +++
1522025739.232270 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24249, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
1522025739.233169 +++ exited with 0 +++
$ strace -tttfe execve bash -c 'sleep 5 >(sleep 6)'
1522025752.162876 execve("/bin/bash", ["bash", "-c", "sleep 5 >(sleep 6)"], [/* 41 vars */]) = 0
strace: Process 24253 attached
[pid 24252] 1522025752.188413 execve("/bin/sleep", ["sleep", "5", "/dev/fd/63"], [/* 41 vars */]) = 0
strace: Process 24254 attached
[pid 24254] 1522025752.191032 execve("/bin/sleep", ["sleep", "6"], [/* 41 vars */]) = 0
sleep: invalid time interval ‘/dev/fd/63’
Try 'sleep --help' for more information.
[pid 24252] 1522025752.197213 +++ exited with 1 +++
[pid 24254] 1522025758.197114 +++ exited with 0 +++
1522025758.197959 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=24254, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
1522025758.198820 +++ exited with 0 +++

command1 and command3 start after command2 and command4 respectively.

They exit whenever their conditions for exiting or being killed are met.


makefifo fifo1; prog2 < fifo1 &; prog1 > fifo1; and makefifo fifo2; prog3 > fifo12 &; prog2 < fifo2; are syntax errors, at least in bash. Even if it weren't, I don't see anything in the redirections that would cause a different execution order from without redirections.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .