Skip to content

Instantly share code, notes, and snippets.

@AntoniosHadji
Created April 11, 2019 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntoniosHadji/d652620bbcee739fa14793e5998a6b8a to your computer and use it in GitHub Desktop.
Save AntoniosHadji/d652620bbcee739fa14793e5998a6b8a to your computer and use it in GitHub Desktop.
test c program for testing python subprocess
#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