19 lines
396 B
C
19 lines
396 B
C
|
#include <stdio.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <unistd.h>
|
||
|
#include <time.h>
|
||
|
|
||
|
int main(int argc, char const *argv[])
|
||
|
{
|
||
|
time_t at = time(NULL);
|
||
|
char buf[32] = "";
|
||
|
sprintf(buf, "%d 运行中", getpid());
|
||
|
write(1, buf, sizeof(buf));
|
||
|
sleep(2);
|
||
|
time_t bt = time(NULL);
|
||
|
printf("\n%d 结束\n", getpid());
|
||
|
printf("运行时间:%ld 秒\n", bt - at);
|
||
|
|
||
|
return 0;
|
||
|
}
|