Skip to content

Instantly share code, notes, and snippets.



Created Apr 11, 2019
What would you like to do?
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;
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;
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