简体   繁体   中英

What is the return value of “times” system call in linux

I am having a legacy function(which is given below) to find the tick count, that means how much time the system is up.

long findtick()
    {
        struct tms buf;
        clock_t tickcount = 0;
        tickcount = times(&buf);
        return (long)tickcount; 
    }

I am not able to find the behaviour of times system call and clock_t structure type.

My doubts are

  1. What is the behaviour and return value of times system call in linux.
  2. What is the structure definition of clock_t
  3. Will this function return tickcount in seconds?
  4. By any chance can this function return -1, because its return type is signed long

I am using gcc compiler in suse 10.

  1. What is the behaviour and return value of times system call in linux.

    Ans : times

  2. What is the structure definition of clock_t

    Ans : typedef clock_t long which is defined in ctime.h

  3. Will this function return tickcount in seconds?

    Ans : yes

  4. By any chance can this function return -1 , because its return type is signed long

    Ans : In failure case, times will return -1

Thanks @cnicutar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM