0

Im writing an application in Rust that checks for certain processes. I know it's possible to get a list of running processes, but i rather not create an infinite loop to poll them.

Is there an event that gets triggered when a process is started?

Solomon Ucko
  • 5,724
  • 3
  • 24
  • 45
Jesse Visser
  • 53
  • 1
  • 9
  • 1
    This depends on your operating system. What OS are you on? The answer is unlikely to be specific to Rust. – Sven Marnach Jun 05 '20 at 14:09
  • Is the process you are monitoring for under your control? Will it create files in a known location you can monitor for instead? At least on Linux, it's a lot easier to monitor for filesystem changes than for processes. – Sven Marnach Jun 05 '20 at 14:13
  • 1
    @SvenMarnach Im using Windows. How would i check if for example Atom or Notepad is started? Does Windows create any files when a process is being started? – Jesse Visser Jun 05 '20 at 15:34
  • Sorry, I've got no clue about Windows. – Sven Marnach Jun 06 '20 at 19:31

1 Answers1

1

Rust can't do anything that the OS doesn't already provide, and Rust doesn't have its own runtime, so you can just use whatever the OS offers.

When there isn't already a crate for some thing, the problem boils down to: How would you do that in C? Find answer to that, and then use Rust's FFI (or some lower-level sys crate like winapi to call that.

Kornel
  • 97,764
  • 37
  • 219
  • 309