Created
April 11, 2019 00:18
-
-
Save AntoniosHadji/d652620bbcee739fa14793e5998a6b8a to your computer and use it in GitHub Desktop.
test c program for testing python subprocess
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _POSIX_C_SOURCE 199309L | |
#include <stdio.h> | |
#include <time.h> | |
int main(int argc,char* argv[]) | |
{ | |
time_t now; | |
time(&now); | |
printf("Today is: %s", ctime(&now)); | |
for (int i = 0; i < 40; i++) { | |
if (i % 7 == 0) { | |
fprintf(stderr, "ERROR: process(%s): %d\n", argv[1], i); | |
} else { | |
fprintf(stdout, "process(%s):%d\n", argv[1], i); | |
} | |
// sleep for 1/10 second | |
nanosleep((const struct timespec[]){{0, 100000000L}}, NULL); | |
} | |
time_t end; | |
time(&end); | |
printf("Elapsed time is: %2.3fs\n", difftime(end, now)); | |
printf("Elapsed time is: %2.3fs\n", (double)(end - now)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment