parent()

Tony Rogvall tony@REDACTED
Tue Aug 31 21:57:19 CEST 2004


måndagen den 30 augusti 2004 kl 17.10 skrev Thomas Lindgren:

>
> Given that it is fairly frequent to pass self() to a
> child process, let me propose that we instead extend
> the BIFs with
>
>    parent()
>
The existing alternative is to use proc_lib then you can extract the 
parent
by  hd(get('$ancestors')).  The parent() BIF is better since you can 
not cheat!


Code example (when using proc_lib:spawn!):

erlang:parent() ->
	case get('$ancestors') of
		[P|_] ->
			case process_info(P, status) of
				undefined -> dead;
				_ -> P
			end;
		_ -> exit(corrupt)
	end.


Regards

/Tony




More information about the erlang-questions mailing list