rashok
rashok

Reputation: 13494

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.

Upvotes: 0

Views: 1784

Answers (1)

rashok
rashok

Reputation: 13494

  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

Upvotes: 1

Related Questions