Re: [Vala] Get correct PID after sudp



Hi,

Thank you very much for your answer. I really can't understand how can I
use it, anyway.

I think I have solved the problem in another theoretical way: can I gain
sudo permissions with a separate command and then keep them as long as I
need?

For example: I may ask for user permissions before the start of the
operation and then release that permission as soon as the operation finish.

Thank you again,
Christian


2013/4/19 Alexander Krivács Schrøder <alexschrod gmail com>

On 19.04.2013 11:35, Christian Capasso wrote:
Hi,

I'm using Process.spawn_async() to launch a process that requires
administrator privileges. This function returns the PID linked to the
sudo
command, which is different from the real PID of the command that I
launched.

For example, if the process launched is "dd", I get a different PID,
which
corresponds to the PID assigned to the sudo command and not to "dd".

Thank you very much in advance,
Christian.
_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list
As far as I can tell, there's no direct way of getting at that PID. In
bash, I would do it by using the PID of the sudo command and the ps
command to get its child PIDs, like so:

$ sudo dd &
$ DD_PID=$(ps --ppid $! -o pid=)
$ echo $DD_PID

(If you're not very familiar with bash, $! is the PID of the last
launched background process, in our case, sudo.)

With that in mind, I think you could either launch and process the
output from ps directly, look into the source code of ps (
http://procps.cvs.sourceforge.net/viewvc/procps/procps/ps/ ) and see how
they get at a process' child PIDs for figuring out how to do it
yourself, or I also think it's possible to get this information from
/proc, if you're willing to go looking around in there...

Hope that helps, and that if I'm wrong, someone else can give a better
answer.


_______________________________________________
vala-list mailing list
vala-list gnome org
https://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]