Comment detail

入出力の中継 (Nested Flatten)
OSProcess インストール済みの Squeak Smalltalk で。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
| pipe1 pipe2 procA procB semaA semaB |
OSProcess accessor canAccessSystem ifFalse: [^self].
pipe1 := OSPipe nonBlockingPipe.
pipe2 := OSPipe nonBlockingPipe.
procA := UnixProcess
   forkJob: 'a'
   arguments: nil
   environment: nil
   descriptors: {pipe1 reader. pipe2 writer. nil}.
procB := UnixProcess
   forkJob: 'b'
   arguments: nil
   environment: nil
   descriptors: {pipe2 reader. pipe1 writer. nil}.
semaA := Semaphore new.
semaB := Semaphore new.
[[Processor yield. procA isComplete] whileFalse. procB sigterm. semaA signal] fork.
[[Processor yield. procB isComplete] whileFalse. procA sigterm. semaB signal] fork.
semaA wait.
semaB wait.
pipe1 close.	
pipe2 close

Index

Feed

Other

Link

Pathtraq

loading...