Skip to main content
typo
Source Link
mikeserv
  • 59.4k
  • 10
  • 122
  • 242

Yes, that's a race condition.

The problem is that the shell starts all processes in the pipeline at the same time and tee truncuatestruncates the output file on startup. If tee is faster then comm the file is empty for comm otherwise it is not.

The pipeline behaviour can be seen if you run this several times (mabe in a loop):

date '+first:  %T'|(cat>&2;sleep 5)|date '+second: %T'

Yes, that's a race condition.

The problem is that the shell starts all processes in the pipeline at the same time and tee truncuates the output file on startup. If tee is faster then comm the file is empty for comm otherwise it is not.

The pipeline behaviour can be seen if you run this several times (mabe in a loop):

date '+first:  %T'|(cat>&2;sleep 5)|date '+second: %T'

Yes, that's a race condition.

The problem is that the shell starts all processes in the pipeline at the same time and tee truncates the output file on startup. If tee is faster then comm the file is empty for comm otherwise it is not.

The pipeline behaviour can be seen if you run this several times (mabe in a loop):

date '+first:  %T'|(cat>&2;sleep 5)|date '+second: %T'
Source Link
Lucas
  • 3k
  • 1
  • 18
  • 26

Yes, that's a race condition.

The problem is that the shell starts all processes in the pipeline at the same time and tee truncuates the output file on startup. If tee is faster then comm the file is empty for comm otherwise it is not.

The pipeline behaviour can be seen if you run this several times (mabe in a loop):

date '+first:  %T'|(cat>&2;sleep 5)|date '+second: %T'