static void install_mimic(const char * const src, const char * const dst, const char * const ref) { const char * const refname = ref != NULL? ref: dst; struct stat sb; if (stat(refname, &sb) == -1) err(1, "Could not stat %s", refname); char owner[20], group[20], mode[6]; snprintf_check(owner, sizeof(owner), "%jd", (intmax_t)sb.st_uid); snprintf_check(group, sizeof(group), "%jd", (intmax_t)sb.st_gid); snprintf_check(mode, sizeof(mode), "%04o", sb.st_mode & 07777); const char * const cmd[] = { "install", "-c", "-o", owner, "-g", group, "-m", mode, "--", src, dst, NULL }; debug_cmd(cmd); const pid_t pid = fork(); if (pid == -1) { err(1, "Could not fork for install(1)"); } else if (pid == 0) { execvp("install", (char * const *)cmd); err(1, "Could not execute install(1)"); } int status; const pid_t wpid = waitpid(pid, &status, 0); if (wpid == -1) err(1, "Could not wait for the install(1) child"); check_wait_result(wpid, status, pid, "install(1)"); }
int handle_cmd(\ char *cmd_buffer) { t_cmd cmd; int ret; ret = 1; cmd = parse_cmd(cmd_buffer); debug_cmd(cmd); if (cmd.not_found) nofound(cmd.arg_v[0]); else if (cmd.builtin) ret = cmd.built(cmd.arg_v); else exec_binary(cmd); free_cmd(&cmd); return (ret); }
void update() { #ifdef _DEBUG debug_cmd(); #endif manager_->update(); }