X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fprocd.git;a=blobdiff_plain;f=upgraded%2Fupgraded.c;h=d7433e76071524a5e69f0e153730b2801e5406b8;hp=1e4057a782ddf412aa2f7361aa9cadb293f0d77c;hb=91da63d3d3fd680c805dd1a1b78df5b8731a8173;hpb=74d835463e05e5761f6f5271e487f299f29d3f07 diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c index 1e4057a..d7433e7 100644 --- a/upgraded/upgraded.c +++ b/upgraded/upgraded.c @@ -18,6 +18,7 @@ #include #include #include +#include #include @@ -55,12 +56,14 @@ int main(int argc, char **argv) { pid_t p = getpid(); - chdir("/tmp"); - if (p != 1) { fprintf(stderr, "this tool needs to run as pid 1\n"); return -1; } + if (chdir("/tmp") == -1) { + fprintf(stderr, "failed to chdir to /tmp: %s\n", strerror(errno)); + return -1; + } if (argc != 2) { fprintf(stderr, "sysupgrade stage 2 failed, no folder specified\n"); return -1;