Sending EOF portably

any way to send EOF down a pipe/io object in a portable fashion? i want to
signal EOF to another process w/o closing/reopen.

-a

···

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================

There seems to be ETX, EOT, EM, FS... in ASCII but I dunno how portable that is.

If you control both processes you can use whatever convention you like. Other than that it'll be difficult.

Btw, why do you want to do that? A named pipe where you want to disconnect a listener but keep the pipe is about the only reasonable scenario that I can think of at the moment.

Kind regards

    robert

···

Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:

any way to send EOF down a pipe/io object in a portable fashion? i
want to signal EOF to another process w/o closing/reopen.

Design your own?

EOF as a marker character is a convention on Unix (usually Ctrl-D, but
mostly interpreted by the shells, etc.) and is a convention on Win32
when the file is opened in ASCII mode (e.g., 'w', not 'wb').

Better to make it so that you've got an explicit EOF marker yourself.

-austin

···

On 9/16/05, Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:

any way to send EOF down a pipe/io object in a portable fashion? i want to
signal EOF to another process w/o closing/reopen.

--
Austin Ziegler * halostatue@gmail.com
               * Alternate: austin@halostatue.ca

Hi,

At Sat, 17 Sep 2005 05:49:51 +0900,
Ara.T.Howard wrote in [ruby-talk:156486]:

any way to send EOF down a pipe/io object in a portable fashion? i want to
signal EOF to another process w/o closing/reopen.

IO#close_write

···

--
Nobu Nakada

but what? the input/output can be arbitraily long binary data so no chars
will work methinks. my understanding is that you can't send eof on *nix -
only a close will do. but ruby has no clearerr... ;-(

cheers.

-a

···

On Sat, 17 Sep 2005, Austin Ziegler wrote:

On 9/16/05, Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:

any way to send EOF down a pipe/io object in a portable fashion? i want to
signal EOF to another process w/o closing/reopen.

Design your own?

EOF as a marker character is a convention on Unix (usually Ctrl-D, but
mostly interpreted by the shells, etc.) and is a convention on Win32
when the file is opened in ASCII mode (e.g., 'w', not 'wb').

Better to make it so that you've got an explicit EOF marker yourself.

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================

any way to send EOF down a pipe/io object in a portable fashion? i
want to signal EOF to another process w/o closing/reopen.

There seems to be ETX, EOT, EM, FS... in ASCII but I dunno how portable that is.
http://www.lookuptables.com/

yeah... but you can't actually send those...

If you control both processes you can use whatever convention you like.
Other than that it'll be difficult.

i don't think i can - the input/output could be any binary data so no sequence
of chars will do.

Btw, why do you want to do that? A named pipe where you want to disconnect
a listener but keep the pipe is about the only reasonable scenario that I
can think of at the moment.

see my acgi posts. right now i have to do

   open environment
   load environment
   close environment

   open stdin
   new cgi using redirected stdin
   close stdin

   open stdout
   open stderr
   redirect stdout
   redirect stderr
   yield cgi
   close stdout
   close stderr

basically i need to be able to do

   io.close
   io.clearerr
   io.read

in both reading/writing scenarios. i'm working on a clearerr module now :wink:

cheers.

-a

···

On Sat, 17 Sep 2005, Robert Klemme wrote:

Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:

--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================

Well, if you have control you can introduce any protocol (even efficient ones) that will work. For example you can simply use an escape character.

If you search the web for "mulitplexing on a single stream" you might find viable solutions, too.

An alternative approach in your case would be to use UNIX domain sockets. They are limited to the local machine and I believe they are faster than TCP/IP sockets. This will also make handling on the server side easier if you have to server multiple clients *concurrently* - even if you initially prevent actual concurrency. (From your description it's not clear to me how you want to prevent two concurrent connections. I may be mistaken but I think there is no way to open a (named) pipe exculsively for writing.)

Kind regards

    robert

···

Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:

On Sat, 17 Sep 2005, Robert Klemme wrote:

Ara.T.Howard <Ara.T.Howard@noaa.gov> wrote:

any way to send EOF down a pipe/io object in a portable fashion? i
want to signal EOF to another process w/o closing/reopen.

There seems to be ETX, EOT, EM, FS... in ASCII but I dunno how
portable that is.
http://www.lookuptables.com/

yeah... but you can't actually send those...

If you control both processes you can use whatever convention you
like. Other than that it'll be difficult.

i don't think i can - the input/output could be any binary data so no
sequence of chars will do.

Well, if you have control you can introduce any protocol (even efficient
ones) that will work. For example you can simply use an escape character.

If you search the web for "mulitplexing on a single stream" you might find
viable solutions, too.

i'll consider.

An alternative approach in your case would be to use UNIX domain sockets.
They are limited to the local machine and I believe they are faster than
TCP/IP sockets. This will also make handling on the server side easier if
you have to server multiple clients *concurrently* - even if you initially
prevent actual concurrency. (From your description it's not clear to me how
you want to prevent two concurrent connections.

i don't think there is a good way to acheive high concurrency using ruby's
thread with io intensive application. i do plan to try a socket
implimentation however. i just want to to K.I.S.S though so we'll see.

I may be mistaken but I think there is no way to open a (named) pipe
exculsively for writing.)

   open('fifo','w').flock File::FILE_EX

or
   require 'posixlock'
   open('fifo','w').posixlock File::FILE_EX

doesn't _open_ it exclusively but it does prevent multiple writers - which is
sufficient.

in my case i just have an auxillary file for this purpose - a filesystem
semaphore if you will.

cheers.

-a

···

On Sat, 17 Sep 2005, Robert Klemme wrote:
--

email :: ara [dot] t [dot] howard [at] noaa [dot] gov
phone :: 303.497.6469
Your life dwells amoung the causes of death
Like a lamp standing in a strong breeze. --Nagarjuna

===============================================================================