Simulating EOF in UNIX C program

Simulating EOF in UNIX C program

Post by Tan Cheng Ya » Tue, 09 Feb 1993 11:00:26



Hi,
   I'm wondering if anyone out there knows how to simulate an
EOF. I need to do the following:

hostname% a | b

program a must send an EOF to b, so that b can start processing.
a MUST still live after sending off the EOF. (b's life status is
not really important).

Any help will be appreciated.

Tan


 
 
 

Simulating EOF in UNIX C program

Post by Ed Fa » Wed, 10 Feb 1993 09:44:12



|   I'm wondering if anyone out there knows how to simulate an
|EOF. I need to do the following:
|
|hostname% a | b
|
|program a must send an EOF to b, so that b can start processing.
|a MUST still live after sending off the EOF. (b's life status is
|not really important).

Have 'a' close stdout.  'b' will see EOF when that happens.

                -ed falk, sun microsystems

To be loyal to rags, to shout for rags, to worship rags, to die for rags
-- that is a loyalty of unreason, it is pure animal (Mark Twain).

 
 
 

Simulating EOF in UNIX C program

Post by Richard Sharm » Sat, 20 Feb 1993 05:17:32


Quote:>  I'm wondering if anyone out there knows how to simulate an
>  EOF. I need to do the following:
>  hostname% a | b
>  program a must send an EOF to b, so that b can start processing.
> a MUST still live after sending off the EOF.

If A closes its stdout, B will see that as an eof condition after it
has read any previous data.    This will not "start B".  Having
    A | B
in Unix [*] means that A and B can be executing concurrently.   If B is
reading faster than A is writing it will get blocked.  Similarly, if A
is writing faster than B is reading it too may be blocked.

[*] Unlike in mdsdos for example, where A must terminate before B starts.