File: qa-pipe

package info (click to toggle)
newlisp 10.7.5-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 6,248 kB
  • sloc: ansic: 33,280; lisp: 4,181; sh: 609; makefile: 215
file content (43 lines) | stat: -rwxr-xr-x 989 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env newlisp


(define (test-pipe)
	(write-file "pipe-child.lsp" 
[text]
(set 'msg (read-line (int (nth 2 (main-args)))))
(write-line (int (nth 3 (main-args))) (upper-case msg))
(exit)
[/text]
	)
  (and
	(set 'channel (pipe))
	(set 'in (first channel))
	(set 'out (last channel))
	(if (find ostype '("Windows" "OS/2"))
		(process (string "newlisp pipe-child.lsp " in " " out))
		(process (string "./newlisp pipe-child.lsp " in " " out)))
	(sleep 1000)
	(write-line out (dup "hello there " 1000))
	(sleep 1000)
	(= (read-line in) (dup "HELLO THERE " 1000))
	(delete-file "pipe-child.lsp")
  )
)

;(if (find ostype '("Linux" "BSD" "OSX" "Solaris" "SunOS" "Aix" "True64Unix" "Cygwin"))
;  (define (test-pipe)
;	(set 'channel (pipe))
;	(set 'in (first channel))
;	(set 'out (last channel))
;	(fork (write-line out (upper-case (read-line in))))
;	(write-line out "hello there")
;	(sleep 2000)
;	(= (read-line in) "HELLO THERE")
;	)
;)

(println "test-pipe => " (test-pipe))

(exit)