[erlang-questions] port_close/1 problem

Serge Aleynikov saleyn@REDACTED
Thu Nov 1 04:45:02 CET 2007


Thanks Per, this is quite clever!

Serge

Per Hedeland wrote:
> 1> Exe = "sleep 1000".
> "sleep 1000"
> 2> Wrapper = "echo $$ | awk '{printf \"%c%c%s\",0,length($1),$1}' >&4; exec ".
> "echo $$ | awk '{printf \"%c%c%s\",0,length($1),$1}' >&4; exec "
> 3> Settings = [binary, {packet, 2}, nouse_stdio, exit_status].
> [binary,{packet,2},nouse_stdio,exit_status]
> 4> Port = open_port({spawn, Wrapper ++ Exe}, Settings).
> #Port<0.95>
> 5> Pid = receive {Port, {data, P}} -> binary_to_list(P) end.
> "97122"
> 6> os:cmd("kill " ++ Pid).
> []
> 7> Status = receive {Port, {exit_status, S}} -> S end.
> 143
> 8> 
> 
> --Per
> 




More information about the erlang-questions mailing list