The "-P" option does not need to read routing table symbols, so there's
no reason to bail if we cannot find them.

Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/main.c,v
retrieving revision 1.108
diff -u -p -r1.108 main.c
--- main.c      23 Oct 2015 08:18:57 -0000      1.108
+++ main.c      29 Dec 2015 10:49:27 -0000
@@ -124,7 +124,8 @@ main(int argc, char *argv[])
        int Tflag = 0;
        int repeatcount = 0;
        int proto = 0;
-       int need_nlist;
+       int need_nlist, kvm_flags = O_RDONLY;
+
 
        af = AF_UNSPEC;
        tableid = getrtable();
@@ -325,10 +326,11 @@ main(int argc, char *argv[])
         * The remaining code may need kvm so lets try to open it.
         * -r and -P are the only bits left that actually can use this.
         */
-       need_nlist = nlistf != NULL || memf != NULL || Pflag || (Aflag && 
rflag);
+       need_nlist = (nlistf != NULL) || (memf != NULL) || (Aflag && rflag);
+       if (!need_nlist && !Pflag)
+               kvm_flags |= KVM_NO_FILES;
 
-       if ((kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY |
-           (need_nlist ? 0 : KVM_NO_FILES), buf)) == NULL)
+       if ((kvmd = kvm_openfiles(nlistf, memf, NULL, kvm_flags, buf)) == NULL)
                errx(1, "kvm_openfiles: %s", buf);
 
        if (need_nlist && (kvm_nlist(kvmd, nl) < 0 || nl[0].n_type == 0)) {

Reply via email to