Although open() syscall returns -1 with an empty string and
is like error handling behavior, checking if the arg is empty
string at the early stage is much better. Hence, we do not
need to pay the overhead of calling the syscall at all.

Signed-off-by: Leesoo Ahn <[email protected]>
---
 libbb/pidfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libbb/pidfile.c b/libbb/pidfile.c
index a6a282562..51432133d 100644
--- a/libbb/pidfile.c
+++ b/libbb/pidfile.c
@@ -20,7 +20,7 @@ void FAST_FUNC write_pidfile(const char *path)
        char buf[sizeof(int)*3 + 2];
        struct stat sb;
 
-       if (!path)
+       if (!path || *path == '\0')
                return;
        /* we will overwrite stale pidfile */
        pid_fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0666);
-- 
2.24.1

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to