Changeset View
Changeset View
Standalone View
Standalone View
usr.bin/diff3/diff3.c
| Show First 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | diffexec(char **diffargv, int fd[]) | ||||
| int pd, error; | int pd, error; | ||||
| if ((error = posix_spawnattr_init(&sa)) != 0) | if ((error = posix_spawnattr_init(&sa)) != 0) | ||||
| errc(2, error, "posix_spawnattr_init"); | errc(2, error, "posix_spawnattr_init"); | ||||
| if ((error = posix_spawn_file_actions_init(&fa)) != 0) | if ((error = posix_spawn_file_actions_init(&fa)) != 0) | ||||
| errc(2, error, "posix_spawn_file_actions_init"); | errc(2, error, "posix_spawn_file_actions_init"); | ||||
| posix_spawnattr_setprocdescp_np(&sa, &pd, 0); | posix_spawnattr_setprocdescp_np(&sa, &pd, 0); | ||||
| posix_spawn_file_actions_addclose(&fa, fd[0]); | |||||
| posix_spawn_file_actions_adddup2(&fa, fd[1], STDOUT_FILENO); | posix_spawn_file_actions_adddup2(&fa, fd[1], STDOUT_FILENO); | ||||
| posix_spawn_file_actions_addclose(&fa, fd[1]); | |||||
| error = posix_spawn(&pid, diffargv[0], &fa, &sa, diffargv, environ); | error = posix_spawn(&pid, diffargv[0], &fa, &sa, diffargv, environ); | ||||
| if (error != 0) | if (error != 0) | ||||
| errc(2, error, "could not spawn diff"); | errc(2, error, "could not spawn diff"); | ||||
| posix_spawn_file_actions_destroy(&fa); | posix_spawn_file_actions_destroy(&fa); | ||||
| posix_spawnattr_destroy(&sa); | posix_spawnattr_destroy(&sa); | ||||
| close(fd[1]); | close(fd[1]); | ||||
| ▲ Show 20 Lines • Show All 748 Lines • ▼ Show 20 Lines | if (caph_rights_limit(fileno(fp[1]), &rights_ro) < 0) | ||||
| err(2, "unable to limit rights on: %s", file2); | err(2, "unable to limit rights on: %s", file2); | ||||
| fp[2] = fopen(file3, "r"); | fp[2] = fopen(file3, "r"); | ||||
| if (fp[2] == NULL) | if (fp[2] == NULL) | ||||
| err(2, "Can't open %s", file3); | err(2, "Can't open %s", file3); | ||||
| if (caph_rights_limit(fileno(fp[2]), &rights_ro) < 0) | if (caph_rights_limit(fileno(fp[2]), &rights_ro) < 0) | ||||
| err(2, "unable to limit rights on: %s", file3); | err(2, "unable to limit rights on: %s", file3); | ||||
| if (pipe(fd13)) | if (pipe2(fd13, O_CLOEXEC)) | ||||
| err(2, "pipe"); | err(2, "pipe"); | ||||
| if (pipe(fd23)) | if (pipe2(fd23, O_CLOEXEC)) | ||||
| err(2, "pipe"); | err(2, "pipe"); | ||||
| diffargv[diffargc] = file1; | diffargv[diffargc] = file1; | ||||
| diffargv[diffargc + 1] = file3; | diffargv[diffargc + 1] = file3; | ||||
| diffargv[diffargc + 2] = NULL; | diffargv[diffargc + 2] = NULL; | ||||
| pd13 = diffexec(diffargv, fd13); | pd13 = diffexec(diffargv, fd13); | ||||
| diffargv[diffargc] = file2; | diffargv[diffargc] = file2; | ||||
| pd23 = diffexec(diffargv, fd23); | pd23 = diffexec(diffargv, fd23); | ||||
| Show All 17 Lines | |||||