[英]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. 我找不到times
系统调用和clock_t
结构类型的行为。
My doubts are 我的怀疑是
times
system call in linux. 什么是行为和返回值times
在Linux系统调用。 clock_t
clock_t
的结构定义是什么 signed long
该函数可以返回-1,因为它的返回类型是signed long
I am using gcc
compiler in suse 10. 我在suse 10中使用gcc
编译器。
What is the behaviour and return value of times system call in linux. Linux中系统调用的行为和返回值是什么?
What is the structure definition of clock_t clock_t的结构定义是什么
Ans : typedef clock_t long
which is defined in ctime.h Ans:在ctime.h中定义的typedef clock_t long
Will this function return tickcount in seconds? 此函数会在几秒钟内返回滴答计数吗?
Ans : yes 答:是的
By any chance can this function return -1
, because its return type is signed long 该函数可能会返回-1
,因为它的返回类型是long签名的
Ans : In failure case, times
will return -1
答:在失败的情况下, times
将返回-1
Thanks @cnicutar 谢谢@cnicutar
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.