2

Looking for way that java be notified when process is created on linux. Instead of polling for process id using ManagementFactory.getRuntimeMXBean().getName(), I want a notification to be raised on linux when a process is created and Java listener to listen for such events and retrieve any possible info abt the process created or spawned by any process.

  • Well, you could probably monitor the "/proc" file system for new directories with "numeric" names. Assuming a Linux only solution is what you're after, precisely what details do you want for each process? – Elliott Frisch Jan 22 '14 at 14:39
  • See http://stackoverflow.com/questions/6075013/linux-detect-launching-of-programs for some ideas. –  Jan 22 '14 at 15:01
  • The above suggestion would require polling to be made on the /proc/loadavg file and the file keeps changing reguarly. Issue is I cannot keep polling. My precise issue is that a process spawns other processes and then dies and mapping them – user2389256 Jan 22 '14 at 16:12
  • My precise issue is that java on linux kicks off processA, which kicks of B, B then starts C and dies. Making it difficut to map A,B and C. Process control groups is one way to do it but I am not sure if it works for dead proceses. Hence, looking for event listener in java which gets notified as soon as process is started. – user2389256 Jan 22 '14 at 16:15
  • The link above points out that there is an easy mechanism to do this without polling, given some C-programming (an example is provided and it compiles + works cleanly). Maybe you could make it so that you'll create a minimal middleware doing receiving the notifications which then notifies whatever you're doing in java? –  Jan 23 '14 at 05:00

0 Answers0