IPC via named pipe: Difference between revisions

Added PicoLisp
(→‎{{header|C}}: If WILL_BLOCK_EVERYTHING, then prevent the "in" pipe blocking everything.)
(Added PicoLisp)
Line 103:
return 0;
}</lang>
 
=={{header|PicoLisp}}==
<lang PicoLisp>(call 'mkfifo "in" "out") # Create pipes
 
(zero *Cnt) # Initialize byte counter
 
(unless (fork) # Handle "out" pipe
(loop
(out "out"
(sync)
(tell)
(prinl *Cnt) ) ) )
 
(unless (fork) # Handle "in" pipe
(in "in"
(loop
(in "in" # Open twice, to avoid broken pipes
(while (rd 1) # (works on Linux, perhaps not POSIX)
(tell 'inc ''*Cnt) ) ) ) ) )
 
(push '*Bye '(call 'rm "in" "out")) # Remove pipes upon exit
(wait) # (Terminate with Ctrl-C)</lang>
Test:
<pre>$ line <out
0
$ echo abc >in
$ line <out
4
$ echo äöü >in
$ line <out
11</pre>
 
=={{header|Ruby}}==
Anonymous user