+ for(i = 0; i < 256; i++) {
+ lut[i][0] = ((i >> 6) * 0x55);
+ lut[i][1] = ((((i >> 3) & 7) * 0x49) >> 1);
+ lut[i][2] = (((i & 7) * 0x49) >> 1);
+ }
+
+ for(i = 0; i < sizeof(screen_conv); i += 3) {
+ screen_conv[i] = lut[screen[i/3]][0];
+ screen_conv[i+1] = lut[screen[i/3]][1];
+ screen_conv[i+2] = lut[screen[i/3]][2];
+ }
+
+ lt = time(NULL);
+ strftime(filename, sizeof(filename), "screen_%Y%m%d-%H%M%S.ppm", localtime(<));
+
+ fp = fopen (filename, "w");
+ fprintf(fp, "P6\n320 234\n255\n");
+ fwrite(screen_conv, sizeof(screen_conv), 1, fp);
+ fclose (fp);
+
+ printf("Waveform saved as %s\n", filename);
+
+ display = fork();
+ switch(display) {
+ case 0:
+ execlp("display", "display", filename, NULL);
+ exit(0);
+ break;
+ case -1:
+ perror("fork");
+ break;
+ default:
+ break;
+ }
+}
+
+void child_reaper(int sig)
+{
+ pid_t child;
+
+ do {
+ child = waitpid(-1, NULL, WNOHANG);
+ } while(child > 0);
+
+}