Bug 228088

Summary: /usr/src/usr.bin/killall/killall.1 - killall recognizes only first option of conjoined option argument
Product: Documentation Reporter: ossbsd
Component: Manual PagesAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Many People CC: doc
Priority: --- Keywords: patch
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
killall.1 patch none

Description ossbsd 2018-05-09 07:13:42 UTC
Created attachment 193199 [details]
killall.1 patch

### Problem
killall uses a custom option parser that silently ignores all but the first option in a conjoined nonargument option set. This behavior differs from that exhibited by the FreeBSD C Standard Library POSIX.1 getopt(3) function. 

### Explication
This user was surprised to find that 
$ killall -zs foo 
did not work as implied by the manpage, a potential pitfall for the unaware. 

A quick perusal of /usr/src/usr.bin/killall.c shows the custom option parser handles option -zs by doing the following (in algol/c ish psuedocode):

av++/ac--
loop  
  ...
  if   **av == '-'         // aha, likely an option
  then ++*av
       switch (**av)) { 
         case 'z':         // yes, it is
         ...               // handle option
         break
       }
  fi                      
  av++/ac--                      // loop driver
pool

Back at loop top, *av now points at what originally was *(av+1). Thus the conjoined option 's' is now buried in string pointed to by *(av-1) and silently ignored. 

### Solution
Either rewrite option parsing to be more POSIXish in behavior, or change the manpage. I take the second approach and attach a patch for the killall.1 manpage.

$ man killall
...
SYNOPSIS
      killall [-delmsvz] [-help] [-I] [-j jail] [-u user] [-t tty]
....

by patch changes to

$ man killall
...
SYNOPSIS
      killall [-d] [-e] [-l] [-m] [-s] [-v] [-z] [-help] [-I] [-j jail] [-u user] [-t tty]
...
 CAVEATS
      This utility silently ignores all but the first member of conjoined
      options. E.g., option -zs is interpreted as if option -z alone were
      present.

### Files
See attached patch.