libc/ukp_setproctitle: Properly handle skipping the executable's name.
commitb866b1dac9e41035fffd5f4cec3b0a24a95916b6
authorSascha Wildner <saw@online.de>
Sat, 4 Mar 2023 02:02:43 +0000 (4 03:02 +0100)
committerSascha Wildner <saw@online.de>
Sat, 4 Mar 2023 02:02:43 +0000 (4 03:02 +0100)
tree7952aa22af96b0cc94fc9c121722c1478d0043df
parent3077094520ec956adf664f1b988f520d913584b6
libc/ukp_setproctitle: Properly handle skipping the executable's name.

If fmt begins with a "-" character, the executable's name should be
skipped. Our fast version of setproctitle() - which is used after the
10th call to setproctitle() - was not handling that correctly.

While here, fix the case where NULL is passed to setproctitle(), which
restores the process title to its original value. Just defer back to
setproctitle() in this case. Thanks to aly for catching that.

Dragonfly-bug: <https://bugs.dragonflybsd.org/issues/3319>
lib/libc/upmap/ukp_setproctitle.c