[/proc] Process watching

Currently, when I ran some game in Epic and exit that game, Epic stays open. This causes game are still visible as running. I think you use wait system call to wait for child process. There is no good way to watch for non-first-level-child. But you can store game command line pattern in game installer/config option. Firstly, we store pid of child we create. Because there is no children’s pid inside /proc/, we must do reverse-recursive-search. We have ppid inside state/status. So, we iterate through each /proc/, comparing cmdline to pattern. If match, we go for each parent process until we found pid we stored. When we found pid we stored, we realized game was ran. We stop timer for search game process, but we must start another timer to monitor if game process ends. When there is no pid of game or cmdline no match pattern, we realize game stops.

I known, that this algorithm is resource-hungry, because we use timer and (when figuring out game starts) iterate each proc. But it will remove bug with displaying that game is running if it does not.

1 Like