[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - passing pipe to process?

passing pipe to process?

Q&A's, tips, howto's

passing pipe to process?

Postby nigelbrown » Thu Nov 27, 2003 2:58 am

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Thu Nov 27, 2003 12:24 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby nigelbrown » Thu Nov 27, 2003 8:37 pm

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby nigelbrown » Thu Nov 27, 2003 9:33 pm

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby nigelbrown » Thu Nov 27, 2003 9:58 pm

No, it seems to wait too:
[nigel@p1300 newlisp_7303]$ newlisp
newLISP v7.3.3 Copyright (c) 2003 Lutz Mueller. All rights reserved.

> (setq pipes (pipe))
(3 4)
> (process "./newlisp dothis.lsp 3 4")
true
> (setq replied (read-line 3))
"hello from process"
> (setq rep2 (read-buffer 3 'buffer 10))

I'm using Mandrake 9.1

Any way of testing pipe to see if input is there?
I want to set a number of processes on potentially long tasks and check for replies.
Hopefully once I get my Quantian (http://dirk.eddelbuettel.com/quantian.html) OpenMosix cluster (home hobby cluster) running
then the processes will distribute across the cluster when running.
If I can't manage them with straight reads then I'll have to think of fancier coordination.

Nigel
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby nigelbrown » Fri Nov 28, 2003 4:27 am

(Apologies if this is sounding more like a blog than a thread)

I will try properly/gracefully closing the pipe from the dothis.lsp end - I was
thinking that program termination would do that but perhaps not.
I'll report back once I've had access to a linux system.

Nigel
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Sat Nov 29, 2003 12:12 am

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby nigelbrown » Sat Nov 29, 2003 6:49 am

Hi,
I found the reason that the read was blocking was that although the process had closed 4 the original newlisp still had it open! Closing 4 in the program that is reading from 3 fixed the blocking viz:
> (pipe)
(3 4)
> (process "./newlisp dothis.lsp 3 4")
true
> (close 4)
true
> (read-buffer 3 'buf 10)
about to read
<read bytes: 10 >
10
> buf
"hello from"
> (read-buffer 3 'buf 10)
about to read
<read bytes: 8 >
8
> buf
" process"
> (read-buffer 3 'buf 10)
about to read
<read bytes: 0 >
0
>

The "about to read" and "read bytes:" are from some debug printf's I used to see what was happening.
What put me on to the problem was this explaination from http://www.opengroup.org/onlinepubs/007 ... read.html::
"When attempting to read from an empty pipe or FIFO:

If no process has the pipe open for writing, read() will return 0 to indicate end-of-file.

If some process has the pipe open for writing and O_NONBLOCK is set, read() will return -1 and set errno to [EAGAIN].

If some process has the pipe open for writing and O_NONBLOCK is clear, read() will block the calling thread until some data is written or the pipe is closed by all processes that had the pipe open for writing. "
<note last paragraph>
It also lines up with advice from the book "Linux programming by example" by Kurt Wall that points out:
"The general rule is that the reader process closes the write end of the pipe and the writer process closes the reader end of the pipe."
by the way dothis.lsp was:
(close 3)
(write-buffer 4 "hello from process" )
(close 4)
(exit)

Hope this serves as a tip for anyone else new to trying out pipes.

Nigel
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Sun Nov 30, 2003 1:35 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby nigelbrown » Fri Dec 12, 2003 12:57 am

regarding the 7.3.17 manual comment:
While read-line will block until a newline character is received, read-buffer will block when less characters than specified are available

read-buffer will not block if the pipe has been closed with less than specified bytes
which can be seen from the fragment

> (read-buffer 3 'buf 10)
about to read
<read bytes: 8 >
8
> buf
" process"

above where the last 8 bytes from the closed pipe are available
and from

> (read-buffer 3 'buf 10)
about to read
<read bytes: 0 >
0
>

where no blocking occues but zero bytes are returned as available fron the closed pipe.

Perhaps docs should read:
read-buffer will block when less characters than specified are available from a pipe that has not had the writiing end closed by all processes.

Nigel


PS I've not looked at read-line blocking at all, particularly what happens if the pipe has been closed but without a newline.
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Fri Dec 12, 2003 1:14 pm

I added "hat has not had the writiing end closed by all processes" in the documentation.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 2 guests

cron