Implement the `c' command in "interactive mode" that displays only commands that match a specified string. Index: m_netbsd.c =================================================================== RCS file: /cvsroot/src/external/bsd/top/dist/machine/m_netbsd.c,v retrieving revision 1.18 diff -u -p -r1.18 m_netbsd.c --- m_netbsd.c 20 Oct 2013 03:02:27 -0000 1.18 +++ m_netbsd.c 21 Dec 2016 08:51:44 -0000 @@ -587,6 +587,7 @@ get_proc_info(struct system_info *si, st int show_idle; int show_system; int show_uid; + char *show_command; static struct handle handle; @@ -626,6 +627,7 @@ get_proc_info(struct system_info *si, st show_idle = sel->idle; show_system = sel->system; show_uid = sel->uid != -1; + show_command = sel->command; /* count up process states and get pointers to interesting procs */ total_procs = 0; @@ -646,9 +648,12 @@ get_proc_info(struct system_info *si, st if (pp->p_stat != LSZOMB && (show_idle || (pp->p_pctcpu != 0) || (pp->p_stat == LSRUN || pp->p_stat == LSONPROC)) && - (!show_uid || pp->p_ruid == (uid_t)sel->uid)) { - *prefp++ = pp; - active_procs++; + (!show_uid || pp->p_ruid == (uid_t)sel->uid) && + (!show_command || + strstr(get_command(sel, pp), + show_command) != NULL)) { + *prefp++ = pp; + active_procs++; } } } @@ -685,6 +690,7 @@ get_lwp_info(struct system_info *si, str int show_idle; int show_system; int show_uid; + char *show_command; static struct handle handle; @@ -736,6 +742,7 @@ get_lwp_info(struct system_info *si, str show_idle = sel->idle; show_system = sel->system; show_uid = sel->uid != -1; + show_command = sel->command; /* count up thread states and get pointers to interesting threads */ total_lwps = 0; @@ -758,9 +765,12 @@ get_lwp_info(struct system_info *si, str if (lp->l_stat != LSZOMB && (show_idle || (lp->l_pctcpu != 0) || (lp->l_stat == LSRUN || lp->l_stat == LSONPROC)) && - (!show_uid || uid_from_thread(lp) == sel->uid)) { - *lrefp++ = lp; - active_lwps++; + (!show_uid || uid_from_thread(lp) == sel->uid) && + (!show_command || + strstr(get_command(sel, proc_from_thread(lp)), + show_command) != NULL)) { + *lrefp++ = lp; + active_lwps++; } } }