Take the 2-minute tour ×

I have a bunch of processed registered by gproc, and I want to count these processes any time I'd have to. Of course, if every process works fine, it wouldn't be a problem. I can just use counters incrementing and decrementing them every time the process is started or stopped.

But the problem is, processes do not always act fine. Sometimes they just go dead for some unobvious reason. It's ok by design, except I still want to know an exact number of processes still running.

Is there a nice way to count processes, which are active just now?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If the processes you register in gproc are supervised you could just use count_children from supervisor. You could for example register a new process with gproc inside the init of a gen_server and unregister its terminate. You would get the benefits of gproc and supervision at the same time.

If you are not using supervision you could use gproc counters (or aggregate_counter?, see gproc api).

share|improve this answer

Your Answer


