(Courriels de diversion: <comporteraient@valides-tapissiers.com> <detroit@fâchais-genouillere.com> <duodecimale@jupettes-laminerons.com> <simplifiait@trepane-traduits.com> <recompte@dolmens-desapprouvaient.com> <acryliques@auditionnera-bizarrement.com> <jongliez@laitage-assiegerez.com> <etagements@hydravion-fassions.com> <bâtee@dirigerais-militaires.com> <pharmacien@demissionnent-aeronavale.com> )


>>>>> "ll" == Laurent Lopes <pes@free.fr> writes:
  ll> Comment savoir si un processus dont on connais le PID existe en
  ll> C. J'ai esayer avec kill(no_du_pid,0), mais &ccedil;a me renvois
  ll> 0 dans les 2 cas (si il existe ou pas).

pourtant c'est bien la méthode à suivre, et je viens de tester que
kill renvoie bien -1 lorsque le pid n'existe pas. Tu peux également
essayer d'ouvrir /proc/<pid> sous Linux ou Solaris.


,---- http://www.faqs.org/faqs/unix-faq/programmer/faq/ --
|
| 1.9 Given a pid, how can I tell if it's a running program?
| ==========================================================
| 
| Use `kill()' with 0 for the signal number.
| 
| There are four possible results from this call:
| 
|    * `kill()' returns 0
| 
|         - this implies that a process exists with the given PID, and the
|           system would allow you to send signals to it. It is
|           system-dependent whether the process could be a zombie.
| 
|    * `kill()' returns -1, `errno == ESRCH'
| 
|         - either no process exists with the given PID, or security
|           enhancements are causing the system to deny its existence. (On
|           some systems, the process could be a zombie.)
| 
|    * `kill()' returns -1, `errno == EPERM'
| 
|         - the system would not allow you to kill the specified process.
|           This means that either the process exists (again, it could be a
|           zombie) or draconian security enhancements are present (e.g. your
|           process is not allowed to send signals to *anybody*).
| 
|    * `kill()' returns -1, with some other value of `errno'
| 
|         - you are in trouble!
| 
| The most-used technique is to assume that success or failure with `EPERM'
| implies that the process exists, and any other error implies that it
| doesn't.
| 
| An alternative exists, if you are writing specifically for a system (or all
| those systems) that provide a `/proc' filesystem: checking for the
| existence of `/proc/PID' may work.
`----

-- 
Eric Marsden                          <URL:http://www.laas.fr/~emarsden/>

---------------------------------------------------------------------
Aide sur la liste: <URL:mailto:linux-31-help@savage.iut-blagnac.fr>Le CULTe sur le web: <URL:http://www.CULTe.org/>