Skip to main content
added 69 characters in body
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

There is no way for the program to distinguish between an EOF that means "it's time to quit" and an EOF that means "a writer is done, but there may be more input from someone else".

If you have the ability to modify the behaviour of your program, then do the reading in an infinite loop (one iteration lasts until EOF) and send it a specific command string that means "time to quit". Sending that string would be the task of the send_eof command in your question.

Another option:

( echo some stuff; cat more_stuff.txt ) >P 

or

{ echo some stuff; cat more_stuff.txt; } >P 

There is no way for the program to distinguish between an EOF that means "it's time to quit" and an EOF that means "a writer is done, but there may be more input from someone else".

If you have the ability to modify the behaviour of your program, then do the reading in an infinite loop (one iteration lasts until EOF) and send it a specific command string that means "time to quit". Sending that string would be the task of the send_eof command in your question.

There is no way for the program to distinguish between an EOF that means "it's time to quit" and an EOF that means "a writer is done, but there may be more input from someone else".

If you have the ability to modify the behaviour of your program, then do the reading in an infinite loop (one iteration lasts until EOF) and send it a specific command string that means "time to quit". Sending that string would be the task of the send_eof command in your question.

Another option:

( echo some stuff; cat more_stuff.txt ) >P 

or

{ echo some stuff; cat more_stuff.txt; } >P 
Source Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k

There is no way for the program to distinguish between an EOF that means "it's time to quit" and an EOF that means "a writer is done, but there may be more input from someone else".

If you have the ability to modify the behaviour of your program, then do the reading in an infinite loop (one iteration lasts until EOF) and send it a specific command string that means "time to quit". Sending that string would be the task of the send_eof command in your question.