csci4061/notes/04-making-processes-code/in-class/sleep_print.c
Michael Zhang 041f660ccd
f
2018-01-29 17:28:37 -06:00

22 lines
346 B
C

#include <time.h>
#include <stdio.h>
#include <stdlib.h>
// usage: sleep_print secs message
int main(int argc, char *argv[]){
int secs = atoi(argv[1]);
struct timespec tm = {
.tv_nsec = 0,
.tv_sec = secs,
};
nanosleep(&tm,NULL);
for(int i=2; i<argc; i++){
printf("%s ",argv[i]);
}
printf("\n");
return secs;
}