On Sat, Jul 01, 2017 at 04:44:14PM +0200, Sebastian Benoit wrote: > This makes netstat show only listening sockets for tcp sockets > when invoked as netstat -l.
> @@ -294,9 +294,14 @@ netdomainpr(struct kinfo_file *kf, int proto) > } > > /* filter listening sockets out unless -a is set */ > - if (!aflag && istcp && kf->t_state <= TCPS_LISTEN) > + if (!(aflag||lflag) && istcp && kf->t_state <= TCPS_LISTEN) > return; > - else if (!aflag && isany) > + else if (!(aflag||lflag) && isany) > + return; > + > + /* when -l is set, show only listening sockets */ > + if (!aflag && lflag && kf->so_type == SOCK_STREAM && > + kf->t_state != TCPS_LISTEN) > return; > Only sockets with protocol tcp have t_state. This check sould be "istcp" like a few lines above instead of "kf->so_type == SOCK_STREAM". otherwise OK bluhm@