minor cleanup

This commit is contained in:
Simon Forman 2019-08-18 12:17:37 -07:00
parent 7d44742317
commit 26c2730273
1 changed files with 7 additions and 11 deletions

View File

@ -11,27 +11,23 @@ fork(Expr, Stack, In, ChildPID) :-
fork_prolog(ChildPID),
bar(ChildPID, In, Out, Expr, Stack).
bar(0, In, Out, Expr, Stack) :-
close(In),
bar(0, In, Out, Expr, Stack) :- close(In),
thun(Expr, Stack, [Result|_]),
w(Out, Result),
close(Out),
w(Out, Result), close(Out),
halt.
bar(PID, _, Out, _, _) :-
integer(PID),
PID =\= 0,
integer(PID), PID =\= 0,
close(Out).
read_pipe(In, Result) :-
select([In], R, [], _, 1500),
(R=[In] ->
read(In, Result)
;
Result=timeout
),
read_pipe_(R, In, Result),
close(In).
read_pipe_([In], In, Result) :- read(In, Result).
read_pipe_( [], _, timeout).
mkpipe(In, Out) :-
create_pipe(In, Out),
set_stream_buffering(Out, none),