On Thu, 2007-11-01 at 10:44 +0200, Andrei Nestor wrote:
> Salut,
> 
> Cum pot sa aflu si eu dintr-un program C daca un anumit proces (cunosc
> PID-ul) mai exista sau nu? Thanks.

Qoutes from `man 2 kill`:

Qoute1:
=======
SYNOPSIS
       #include <sys/types.h>
       #include <signal.h>

       int kill(pid_t pid, int sig);
=======

Qoute2:
=======
RETURN VALUE
        On success (at least one signal was sent), zero is returned.  On
        error, -1 is returned, and errno is set appropriately.

ERRORS
        EINVAL An invalid signal was specified.

        EPERM  The process does not have permission to send the signal
        to  any of the target processes.

        ESRCH  The  pid or process group does not exist.  Note that an
        existing process might be a zombie, a  process  which  already
        committed termination, but has not yet been wait()ed for.
========

Qoute3:

========
        If sig is 0, then no signal is sent, but error checking is
        still  performed.
========


Drept concluzie: kill(pid, 0) si verifici return code + errno. 

NB: Trebuie ca in programul tau C sa ai aceleasi privilegii ca si
procesul urmarit.



-- 
Spami.



_______________________________________________
RLUG mailing list
[email protected]
http://lists.lug.ro/mailman/listinfo/rlug

Raspunde prin e-mail lui