sleep()用法请教
从打印结果来看,pid1与pid2之间没有时间间隔,相反,pid2与pid1之间却间隔5秒,请大神解释一下!#include <stdio.h>
#include <sys/time.h>
void main()
{
while(1)
{
struct timeval newtime;
gettimeofday(&newtime, NULL);
fprintf(stderr, "pid1=%d sTime=%5ld\n", getpid(),newtime.tv_sec);
sleep(5);
fprintf(stderr, "pid2=%d sTime=%5ld\n", getpid(),newtime.tv_sec);
}
}