]> Trent Huber's Code - cbs.git/commitdiff
build() tweaks
authorTrent Huber <trentmhuber@gmail.com>
Thu, 7 Aug 2025 00:27:12 +0000 (20:27 -0400)
committerTrent Huber <trentmhuber@gmail.com>
Thu, 7 Aug 2025 00:27:12 +0000 (20:27 -0400)
cbs.c

diff --git a/cbs.c b/cbs.c
index fcbe83bb7f512baff2815b876fcbc6eb7531f487..58ab3222b004c109d7ff761f3373e3b37160c6b1 100644 (file)
--- a/cbs.c
+++ b/cbs.c
@@ -152,15 +152,14 @@ void load(char type, char *target, char **objs) {
 
 void build(char *path) {
    char *absolute, *current;
-   pid_t cpid;
    int self, exists, rebuild;
+   pid_t cpid;
    struct stat src, exe;
 
    if (!(absolute = realpath(path, NULL)))
        err(EXIT_FAILURE, "Unable to resolve `%s'", path);
    if (!(current = getcwd(NULL, 0)))
        err(EXIT_FAILURE, "Unable to check current directory");
-   cpid = 0;
 
    if (!(self = strcmp(absolute, current) == 0)) {
        if ((cpid = fork()) == -1) err(EXIT_FAILURE, "Unable to fork");
@@ -170,7 +169,7 @@ void build(char *path) {
        printf("cd %s/\n", path);
        if (chdir(path) == -1)
            err(EXIT_FAILURE, "Unable to change directory to `%s'", path);
-   }
+   } else cpid = 0;
 
    free(absolute);
    free(current);