Linux. How to get grand child pid ?

Все, что вы хотели знать о программизме, но боялись спросить.
Ответить
Аватара пользователя
dima
Житель
Сообщения: 690
Зарегистрирован: 19 фев 2003, 19:26
Откуда: Хабаровск->Toronto

Linux. How to get grand child pid ?

Сообщение dima »

my program start process "gnome-open file1.pdf". as result pdfviewer opens file1.pdf on desktop.

I need from my program to know when pdfviewer will be closed.
Any ideas how to do that ?

no, I can't start pdfviewer directly (not at this point at least)

Crazy idea - enumerate all processes in system to get all that have file1.pdf and ppid = 1. Start gnome-open and wait while it exit. enumerate all processes again with same condition (has file1.pdf in command line and ppid = 1). Exclude pids from first run. Hopefully it will be only one.

what do you think ?
Аватара пользователя
Groundhog
Графоман
Сообщения: 5101
Зарегистрирован: 20 авг 2005, 16:36
Откуда: Vancouver

Re: Linux. How to get grand child pid ?

Сообщение Groundhog »

Все уже своровано до нас:
Посмотри ps
Если скрипт с поддержкой системных комманд - просто типа ps axjf и парзе оутпут.
Или в ps сорсе ныряй если необходимо - посмотри как сделано.
Ответить