Reputation: 13494
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
times
system call in linux.clock_t
signed long
I am using gcc
compiler in suse 10.
Upvotes: 0
Views: 1784
Reputation: 13494
What is the behaviour and return value of times system call in linux.
Ans : times
What is the structure definition of clock_t
Ans : typedef clock_t long
which is defined in ctime.h
Will this function return tickcount in seconds?
Ans : yes
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