openDocument and openURL leave zombie processes
Original Reporter info from Mantis: fedkad
-
Reporter name: Fedon Kadifeli
Original Reporter info from Mantis: fedkad
- Reporter name: Fedon Kadifeli
Description:
Each time I call openDocument to open a file or openURL to open a web address in the default browser, I see accumulating defunct processes. The parent process of these is my calling program. The underlying code of these procedures should wait for xdg-open process to return.
Recommended patch:
To solve this, I added the following line to file components/lazutils/utf8process.pp, line 234 (at procedure RunCmdFromPath):
BrowserProcess.Options := BrowserProcess.Options + [poWaitOnExit];
Steps to reproduce:
Run a code like this in a Lazarus program:
OpenDocument('/home/me/Documents/text.txt');
Gedit will open. Without closing the calling Lazarus program, run the following bash command
ps -ef | grep -i defunct
A defunct process (child of the Lazarus program) will appear.
Additional information:
Discussed in https://forum.lazarus.freepascal.org/index.php?topic=45271