minor cleanup
This commit is contained in:
parent
7d44742317
commit
26c2730273
|
|
@ -11,27 +11,23 @@ fork(Expr, Stack, In, ChildPID) :-
|
||||||
fork_prolog(ChildPID),
|
fork_prolog(ChildPID),
|
||||||
bar(ChildPID, In, Out, Expr, Stack).
|
bar(ChildPID, In, Out, Expr, Stack).
|
||||||
|
|
||||||
bar(0, In, Out, Expr, Stack) :-
|
bar(0, In, Out, Expr, Stack) :- close(In),
|
||||||
close(In),
|
|
||||||
thun(Expr, Stack, [Result|_]),
|
thun(Expr, Stack, [Result|_]),
|
||||||
w(Out, Result),
|
w(Out, Result), close(Out),
|
||||||
close(Out),
|
|
||||||
halt.
|
halt.
|
||||||
|
|
||||||
bar(PID, _, Out, _, _) :-
|
bar(PID, _, Out, _, _) :-
|
||||||
integer(PID),
|
integer(PID), PID =\= 0,
|
||||||
PID =\= 0,
|
|
||||||
close(Out).
|
close(Out).
|
||||||
|
|
||||||
read_pipe(In, Result) :-
|
read_pipe(In, Result) :-
|
||||||
select([In], R, [], _, 1500),
|
select([In], R, [], _, 1500),
|
||||||
(R=[In] ->
|
read_pipe_(R, In, Result),
|
||||||
read(In, Result)
|
|
||||||
;
|
|
||||||
Result=timeout
|
|
||||||
),
|
|
||||||
close(In).
|
close(In).
|
||||||
|
|
||||||
|
read_pipe_([In], In, Result) :- read(In, Result).
|
||||||
|
read_pipe_( [], _, timeout).
|
||||||
|
|
||||||
mkpipe(In, Out) :-
|
mkpipe(In, Out) :-
|
||||||
create_pipe(In, Out),
|
create_pipe(In, Out),
|
||||||
set_stream_buffering(Out, none),
|
set_stream_buffering(Out, none),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue