Skip to content

Instantly share code, notes, and snippets.

@nathanwiegand
Created February 22, 2010 16:36
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 nathanwiegand/311236 to your computer and use it in GitHub Desktop.
Save nathanwiegand/311236 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <strings.h>
#include <sys/types.h>
int main(int argc, char **argv) {
int i;
unsigned int outputFD;
FILE *outputFile;
FILE *inputStream;
for(i = 0; i < argc; i++) {
if(!strcmp(argv[i], "--hotswapping")) {
int reader = atoi(argv[++i]);
inputStream = fdopen(reader, "r");
}
}
fscanf(inputStream, "%d", &i);
fscanf(inputStream, "%u", &outputFD);
fclose(inputStream);
outputFile = fdopen(outputFD, "w");
for(;;i++) {
printf("New Binary:\t%d My PID=%d\n", i, getpid());
fflush(stdout);
fprintf(outputFile, "New Binary:\t%d My PID=%d\n", i, getpid());
fflush(outputFile);
sleep(1);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment