/* Gets previews of PDF Documents */ void getPDFPreview(char *filepath, int maxy, int maxx) { char imgout[] = "/tmp/prev.jpg"; pid_t pid; pid = fork(); struct sigaction act; sigemptyset(&act.sa_mask); act.sa_flags = 0; act.sa_handler = cb_sig; if(pid == 0) { execlp("pdftoppm","pdftoppm","-l","1","-jpeg",filepath,"-singlefile", "/tmp/prev", (char *)NULL); exit(1); } else { //int status; //waitpid(pid, &status, 0); if (ERR == wgetch(current_win)) { printf("wgetch interrupted by signal\n"); } else { raise(SIGUSR1); } if (raised_signal == SIGUSR1) { kill(pid, SIGINT); } else if (raised_signal == SIGCHLD) { getImgPreview(imgout, maxy, maxx); clearFlagImg = 1; } } }