Rafael Sadowski said: > here is a third and last try to push vifm in ports tree.
Now that we have pledge(2), it would probably be a better idea to use libmagic with fork+pledge. | + /* replace single quotes with double */ | + if (strchr(filename, '\'')) | { | - return -1; | + qp = quoted_filename; | + | + do { | + if (*filename == '\'') | + *qp++ = '\\'; | + *qp++ = *filename; | + } while (*filename++ != '\0'); | + | + filename = quoted_filename; | } This is not needed. And even if it was, comment should have been different. | + switch (fork()) | { | - pclose(pipe); | - return -1; | + case -1: | + printf("ERROR: forking child process failed\n"); | + return -1; | + case 0: | + dup2 (pipes[1], STDOUT_FILENO); | + close(pipes[0]); | + close(pipes[1]); | + /* Use the file command to get mimetype */ | + execl("/usr/bin/file", "file", "-b", "--mime-type", filename); | + exit(0); | + default: | + close(pipes[1]); | + (void)read(pipes[0], buf, buf_sz); Shouldn't the parent process wait(2) for child? -- Dmitrij D. Czarkoff