unix pid

Michael McDaniel erlang@REDACTED
Sat Jul 9 18:05:25 CEST 2005


On Sat, Jul 09, 2005 at 03:15:13PM +0200, Róbert Balogh (IJ/ETH) wrote:
> Hej erlang experts,
> 
> I'd like to ask You if I'm on UNIX/Linux system and I do eq: os:cmd(cmdtool). in erlang, how possible to know the pid of that process what is created by this?
> 
> thanks a lot for Your help.
> 
> br,
> /Robi
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I am not certain I understand your question.  The following may be of assistance.

The first example (1>, 2>) shows Erlang system information about the PID returned from the
Erlang process.  Note I ran spawn/3 otherwise the os:cmd/1 would not return until after
"sleep 7" finished.

The second example (3>, 4>) shows host OS PID of the background 'find /' process.
Note I ran "find / &" as background process.


$ erl
Erlang (BEAM) emulator version 5.4.8 [hipe]

Eshell V5.4.8  (abort with ^G)
1> spawn(os, cmd, ["sleep 7"]).
<0.35.0>
2> i(0,35,0).
[{current_function,{os,unix_cmd,1}},
 {initial_call,{os,cmd,1}},
 {status,waiting},
 {message_queue_len,0},
 {messages,[]},
 {links,[<0.36.0>]},
 {dictionary,[]},
 {trap_exit,false},
 {error_handler,error_handler},
 {priority,normal},
 {group_leader,<0.24.0>},
 {heap_size,233},
 {stack_size,3},
 {reductions,14},
 {garbage_collection,[{fullsweep_after,65535}]}]
3> 
3> os:cmd("find / &").
[]
4> os:cmd("ps xauw | egrep find | egrep -v grep").
"mmcdanie 10468  0.0  0.1  2552  700 ?        D    08:55   0:03 find /\n"
5> 

~Michael



More information about the erlang-questions mailing list