+ png = lcd2png(screen, &imglen);
+
+ lt = time(NULL);
+ strftime(filename, sizeof(filename), "screen_%Y%m%d-%H%M%S.png", localtime(<));
+ fd=open(filename, O_CREAT|O_WRONLY, 0644);
+ if (fd == -1) {
+ perror("open");
+ exit(EXIT_FAILURE);
+ }
+
+ while(imglen > 0) {
+ ret = write(fd, png, imglen);
+ if (ret == -1) {
+ perror("write");
+ exit(EXIT_FAILURE);
+ }
+ imglen -= ret;
+ }
+ close(fd);
+ free(png);
+
+ 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);
+
+}