Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
Signed-off-by: leleliu008 <leleliu008@gmail.com>
  • Loading branch information
leleliu008 committed Mar 13, 2024
1 parent e8876bd commit d4cc76d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/uppm-formula-repo-sync.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static int uppm_formula_repo_sync_official_core_internal(const char * formulaRep
return ret;
}

fprintf(stderr, "updating uppm formula repository from %s\n", formulaRepoUrl);
fprintf(stderr, "uppm updating formula repository from %s\n", formulaRepoUrl);

ret = ppkg_git_sync(formulaRepoDIR, formulaRepoUrl, "refs/heads/master", "refs/remote/heads/master", "master", 0);

Expand Down
37 changes: 25 additions & 12 deletions src/uppm-install.c
Original file line number Diff line number Diff line change
Expand Up @@ -607,25 +607,38 @@ int uppm_install(const char * packageName, const bool verbose, const bool force)

printf("run shell code:\n%s\n", shellCode);

int childProcessExitStatusCode = system(shellCode);
pid_t pid = fork();

if (childProcessExitStatusCode == -1) {
if (pid == -1) {
perror(NULL);
uppm_formula_free(formula);
return PPKG_ERROR;
}

if (childProcessExitStatusCode != 0) {
if (WIFEXITED(childProcessExitStatusCode)) {
fprintf(stderr, "running shell code exit with status code: %d\n", WEXITSTATUS(childProcessExitStatusCode));
} else if (WIFSIGNALED(childProcessExitStatusCode)) {
fprintf(stderr, "running shell code killed by signal: %d\n", WTERMSIG(childProcessExitStatusCode));
} else if (WIFSTOPPED(childProcessExitStatusCode)) {
fprintf(stderr, "running shell code stopped by signal: %d\n", WSTOPSIG(childProcessExitStatusCode));
if (pid == 0) {
execl("/bin/sh", "/bin/sh", "-c", shellCode);
perror("/bin/sh");
exit(255);
} else {
int childProcessExitStatusCode;

if (waitpid(pid, &childProcessExitStatusCode, 0) < 0) {
perror(NULL);
uppm_formula_free(formula);
return PPKG_ERROR;
}

uppm_formula_free(formula);
return PPKG_ERROR;
if (childProcessExitStatusCode != 0) {
if (WIFEXITED(childProcessExitStatusCode)) {
fprintf(stderr, "running shell code exit with status code: %d\n", WEXITSTATUS(childProcessExitStatusCode));
} else if (WIFSIGNALED(childProcessExitStatusCode)) {
fprintf(stderr, "running shell code killed by signal: %d\n", WTERMSIG(childProcessExitStatusCode));
} else if (WIFSTOPPED(childProcessExitStatusCode)) {
fprintf(stderr, "running shell code stopped by signal: %d\n", WSTOPSIG(childProcessExitStatusCode));
}

uppm_formula_free(formula);
return PPKG_ERROR;
}
}
}

Expand Down

0 comments on commit d4cc76d

Please sign in to comment.