Provided by: manpages-fr-dev_4.13-4_all bug

NOM

       clock_getcpuclockid - Obtenir l'identifiant de l'horloge CPU d'un processus

SYNOPSIS

       #include <time.h>

       int clock_getcpuclockid(pid_t pid, clockid_t *clockid);

       Lier avec -lrt (seulement pour les versions de glibc antérieures à 2.17).

   Exigences de macros de test de fonctionnalités pour la glibc (consulter feature_test_macros(7)) :

       clock_getcpuclockid() :
           _POSIX_C_SOURCE >= 200112L

DESCRIPTION

       The  clock_getcpuclockid()  function obtains the ID of the CPU-time clock of the process whose ID is pid,
       and returns it in the location pointed to by clockid. If pid is zero, then the clock ID of  the  CPU-time
       clock of the calling process is returned.

VALEUR RENVOYÉE

       En  cas  de  réussite,  clock_getcpuclockid() renvoie 0. En cas d'erreur, elle renvoie un numéro d'erreur
       positif listé dans ERRORS.

ERREURS

       ENOSYS Le noyau ne permet pas d'obtenir l'horloge CPU d'un autre processus et pid ne  correspond  pas  au
              processus appelant.

       EPERM  The  caller does not have permission to access the CPU-time clock of the process specified by pid.
              (Specified in POSIX.1-2001; does not occur on Linux unless the kernel does not  support  obtaining
              the per-process CPU-time clock of another process.)

       ESRCH  Il n'y a pas de processus ayant pour identifiant pid

VERSIONS

       La fonction clock_getcpuclockid() est disponible dans la glibc depuis la version 2.2.

ATTRIBUTS

       Pour une explication des termes utilisés dans cette section, consulter attributes(7).
       ┌───────────────────────┬──────────────────────┬─────────┐
       │ InterfaceAttributValeur  │
       ├───────────────────────┼──────────────────────┼─────────┤
       │ clock_getcpuclockid() │ Sécurité des threads │ MT-Safe │
       └───────────────────────┴──────────────────────┴─────────┘

CONFORMITÉ

       POSIX.1-2001, POSIX.1-2008.

NOTES

       Un appel à clock_gettime(2) avec l'identifiant d'horloge obtenu par un appel à clock_getcpuclockid() avec
       un pid de 0 revient à utiliser l'identifiant d'horloge CLOCK_PROCESS_CPUTIME_ID.

EXEMPLES

       Le  programme d'exemple ci-dessous obtient l'identifiant de l'horloge CPU du processus dont l'identifiant
       est fourni sur la ligne de commande, puis utilise clock_gettime(2) pour obtenir l'heure de cette horloge.
       Un exemple d'exécution suit :

           $ ./a.out 1                 # Show CPU clock of init process
           CPU-time clock for PID 1 is 2.213466748 seconds

   Source du programme

       #define _XOPEN_SOURCE 600
       #include <stdint.h>
       #include <stdio.h>
       #include <unistd.h>
       #include <stdlib.h>
       #include <time.h>

       int
       main(int argc, char *argv[])
       {
           clockid_t clockid;
           struct timespec ts;

           if (argc != 2) {
               fprintf(stderr, "%s <process-ID>\n", argv[0]);
               exit(EXIT_FAILURE);
           }

           if (clock_getcpuclockid(atoi(argv[1]), &clockid) != 0) {
               perror("clock_getcpuclockid");
               exit(EXIT_FAILURE);
           }

           if (clock_gettime(clockid, &ts) == -1) {
               perror("clock_gettime");
               exit(EXIT_FAILURE);
           }

           printf("CPU-time clock for PID %s is %jd.%09ld seconds\n",
                   argv[1], (intmax_t) ts.tv_sec, ts.tv_nsec);
           exit(EXIT_SUCCESS);
       }

VOIR AUSSI

       clock_getres(2), timer_create(2), pthread_getcpuclockid(3), time(7)

COLOPHON

       Cette page fait partie de la publication 5.10 du projet man-pages Linux. Une description du projet et des
       instructions pour signaler des anomalies et la dernière version de cette page  peuvent  être  trouvées  à
       l'adresse https://www.kernel.org/doc/man-pages/.

TRADUCTION

       La   traduction   française   de   cette   page   de   manuel   a   été   créée   par  Christophe  Blaess
       <https://www.blaess.fr/christophe/>,   Stéphan   Rafin   <stephan.rafin@laposte.net>,   Thierry   Vignaud
       <tvignaud@mandriva.com>,  François  Micaux,  Alain Portal <aportal@univ-montp2.fr>, Jean-Philippe Guérard
       <fevrier@tigreraye.org>,   Jean-Luc   Coulon   (f5ibh)   <jean-luc.coulon@wanadoo.fr>,   Julien   Cristau
       <jcristau@debian.org>,      Thomas      Huriaux      <thomas.huriaux@gmail.com>,     Nicolas     François
       <nicolas.francois@centraliens.net>,    Florentin    Duneau    <fduneau@gmail.com>,     Simon     Paillard
       <simon.paillard@resel.enst-bretagne.fr>,    Denis    Barbier   <barbier@debian.org>   et   David   Prévot
       <david@tilapin.org>

       Cette traduction est une documentation libre ; veuillez vous  reporter  à  la  GNU General Public License
       version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.

       Si  vous  découvrez  un  bogue  dans la traduction de cette page de manuel, veuillez envoyer un message à
       debian-l10n-french@lists.debian.org.

Linux                                            1 novembre 2020                          CLOCK_GETCPUCLOCKID(3)