[erlang-questions] Manually remove a message from Process Mailbox

Tony Rogvall <>
Fri Jan 4 20:51:12 CET 2013

And happy new year.

If you also simulate send you could send with a unique reference:
	Pid !  Message
	Pid ! {make_ref(), Message}

Then you can get the k'th message {Ref,Message} and do a selective receive to remove that message:

		{Ref,_Message} -> ok

A bit on the heavy side, but fun.  
Handling timeout is a bit more tricky, but solvable with the above schema.


On 4 jan 2013, at 20:22, Aggelos Giantsios <> wrote:

> Happy New Year to everyone!
> I am trying to simulate the 'receive' expression behaviour.
> I access the process message queue with erlang:process_info(self(), messages).
> Assuming I have selected a message Msg which is at position k in the message list and have safely stored it in a variable,
> is there a way to manually remove Msg from the process message queue?
> Thanks,
> Aggelos
> _______________________________________________
> erlang-questions mailing list
> http://erlang.org/mailman/listinfo/erlang-questions

"Installing applications can lead to corruption over time. Applications gradually write over each other's libraries, partial upgrades occur, user and system errors happen, and minute changes may be unnoticeable and difficult to fix"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20130104/a1b354ae/attachment.html>

More information about the erlang-questions mailing list