mirror of https://github.com/nealey/irc-bot
Fix process bug
This commit is contained in:
parent
f7db0e10d0
commit
f97281cc2b
26
process.ml
26
process.ml
|
@ -8,6 +8,7 @@ let spawn prog args =
|
||||||
Unix.close fd0_exit;
|
Unix.close fd0_exit;
|
||||||
|
|
||||||
Unix.dup2 fd1_entr Unix.stdout;
|
Unix.dup2 fd1_entr Unix.stdout;
|
||||||
|
Unix.dup2 fd1_entr Unix.stderr;
|
||||||
Unix.close fd1_entr;
|
Unix.close fd1_entr;
|
||||||
Unix.close fd1_exit;
|
Unix.close fd1_exit;
|
||||||
|
|
||||||
|
@ -53,21 +54,15 @@ let canned_handler d p fd event =
|
||||||
p.finished (String.sub p.stdout 0 p.stdout_pos)
|
p.finished (String.sub p.stdout 0 p.stdout_pos)
|
||||||
end
|
end
|
||||||
| Dispatch.Output ->
|
| Dispatch.Output ->
|
||||||
begin
|
let len =
|
||||||
try
|
Unix.write fd p.stdin p.stdin_pos
|
||||||
let len =
|
((String.length p.stdin) - p.stdin_pos)
|
||||||
Unix.write fd p.stdin p.stdin_pos
|
in
|
||||||
((String.length p.stdin) - p.stdin_pos)
|
p.stdin_pos <- p.stdin_pos + len;
|
||||||
in
|
if (p.stdin_pos == String.length p.stdin) then begin
|
||||||
p.stdin_pos <- p.stdin_pos + len;
|
|
||||||
if (p.stdin_pos == String.length p.stdin) then begin
|
|
||||||
Unix.close fd;
|
|
||||||
Dispatch.delete d fd
|
|
||||||
end
|
|
||||||
with Unix.Unix_error _ ->
|
|
||||||
Unix.close fd;
|
Unix.close fd;
|
||||||
Dispatch.delete d fd
|
Dispatch.delete d fd
|
||||||
end
|
end
|
||||||
| Dispatch.Exception ->
|
| Dispatch.Exception ->
|
||||||
()
|
()
|
||||||
|
|
||||||
|
@ -100,9 +95,6 @@ let rec sigchld s =
|
||||||
with Unix.Unix_error (Unix.ECHILD, _, _) ->
|
with Unix.Unix_error (Unix.ECHILD, _, _) ->
|
||||||
()
|
()
|
||||||
|
|
||||||
let sigpipe s = ()
|
|
||||||
|
|
||||||
let _ =
|
let _ =
|
||||||
Sys.set_signal Sys.sigchld (Sys.Signal_handle sigchld);
|
Sys.set_signal Sys.sigchld (Sys.Signal_handle sigchld)
|
||||||
Sys.set_signal Sys.sigpipe (Sys.Signal_handle sigpipe)
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue