From: Craig Small Date: Tue, 16 Sep 2003 11:26:27 +0000 (+0000) Subject: pstree.x11 and icons X-Git-Tag: v22.11~176 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dfe683f03b4f57125058d9c7d41e8dff90b8a899;p=psmisc pstree.x11 and icons --- diff --git a/ChangeLog b/ChangeLog index 146778b..f92b972 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,8 @@ not yet released Craig Small * fuser -ki now tells user default is N Closes Debian: #197356 * pstree -a doesn't print space at end of line Closes Debian: #182099 * Works with new sort flags +2 -> -k 3 Thankyou Andrew Walrond + * pstree.x11 now just pstree with a trick Closes Debian: #201042 + * Icons for pstree, thankyou Tatlin! Closes Debian: #192636 Changes in 21.3 =============== diff --git a/README b/README index 60c7031..9c1e98c 100644 --- a/README +++ b/README @@ -23,4 +23,9 @@ files to make psmisc speak different languages. If your language is not supported then let me know, all it takes is translating one file in a certain manner. +Icons +----- +The pstree icons were drawn by Tatlin at Coresis who has given permission +for them to be used for psmisc. + - Craig diff --git a/doc/killall.1 b/doc/killall.1 index 840ad05..6a63a45 100644 --- a/doc/killall.1 +++ b/doc/killall.1 @@ -92,5 +92,5 @@ Werner Almesberger wrote the original version of psmisc. Since version 20 Craig Small can be blamed. .SH "SEE ALSO" -.BR kill (1), fuser (1), pgrep (1), pidof (1), ps (1), kill (2) +.BR kill (1), fuser (1), pgrep (1), pidof (1), pkill (1), ps (1), kill (2) .\"{{{}}} diff --git a/doc/pstree.1 b/doc/pstree.1 index 5f9f3d1..0ad6065 100644 --- a/doc/pstree.1 +++ b/doc/pstree.1 @@ -3,7 +3,7 @@ pstree \- display a tree of processes .SH SYNOPSIS .ad l -.B pstree +.B pstree .RB [ \-a ] .RB [ \-c ] .RB [ \-h | \-H \fIpid\fB ] @@ -39,6 +39,11 @@ becomes init\-\-\-4*[getty] .sp .fi +.PP +If \fBpstree\fR is called as \fBpstree.x11\fR then it will prompt the user +at the end of the line to press return and will not return until that +has happened. This is useful for when \fBpstree\fR is run in a xterminal. + .SH OPTIONS .IP \fB\-a\fP Show command line arguments. If the command line of a process is swapped out, @@ -82,8 +87,9 @@ Display version information. .nf /proc location of the proc file system .fi -.SH AUTHOR +.SH AUTHORS Werner Almesberger +Craig Small .SH "SEE ALSO" ps(1), top(1) .\"{{{}}} diff --git a/icons/psmisc16.gif b/icons/psmisc16.gif new file mode 100644 index 0000000..2143306 Binary files /dev/null and b/icons/psmisc16.gif differ diff --git a/icons/psmisc32.gif b/icons/psmisc32.gif new file mode 100644 index 0000000..567041d Binary files /dev/null and b/icons/psmisc32.gif differ diff --git a/icons/pstree16.xpm b/icons/pstree16.xpm new file mode 100644 index 0000000..4f7e412 --- /dev/null +++ b/icons/pstree16.xpm @@ -0,0 +1,50 @@ +/* XPM */ +static char * icon_16x16_xpm[] = { +"16 16 31 1", +" c None", +". c #4E1C0D", +"+ c #A1CDA4", +"@ c #73F91C", +"# c #D4880C", +"$ c #8D320A", +"% c #DE8F69", +"& c #67FC03", +"* c #AA6D53", +"= c #99F56C", +"- c #AA9177", +"; c #AA4509", +"> c #6CF10A", +", c #CB7502", +"' c #3B7529", +") c #D06938", +"! c #A5610F", +"~ c #86D83B", +"{ c #CC8346", +"] c #B97428", +"^ c #864909", +"/ c #7FF432", +"( c #C65707", +"_ c #709081", +": c #BD300E", +"< c #68FC04", +"[ c #A44C36", +"} c #757408", +"| c #60E804", +"1 c #927136", +"2 c #6D473C", +" ", +" ", +" ,,, _ ", +" ,#%{,): ", +" ###,]!({ ", +" %#{#,*;(:) ", +" ##{]][^]$$; ", +" ,,{]#{());$:$1 ", +" {,*:!^22:^%)$- ", +" {)$-)^;:!$2.%1 ", +" !(2._[!$$.*((+ ", +" {[*1}$..$!- ", +" ^. ", +" .' ", +" _'.'' ", +" "}; diff --git a/icons/pstree32.xpm b/icons/pstree32.xpm new file mode 100644 index 0000000..ed79a82 --- /dev/null +++ b/icons/pstree32.xpm @@ -0,0 +1,66 @@ +/* XPM */ +static char * icon_32x32_xpm[] = { +"32 32 31 1", +" c None", +". c #4E1C0D", +"+ c #A1CDA4", +"@ c #73F91C", +"# c #D4880C", +"$ c #8D320A", +"% c #DE8F69", +"& c #67FC03", +"* c #AA6D53", +"= c #99F56C", +"- c #AA9177", +"; c #AA4509", +"> c #6CF10A", +", c #CB7502", +"' c #3B7529", +") c #D06938", +"! c #A5610F", +"~ c #86D83B", +"{ c #CC8346", +"] c #B97428", +"^ c #864909", +"/ c #7FF432", +"( c #C65707", +"_ c #709081", +": c #BD300E", +"< c #68FC04", +"[ c #A44C36", +"} c #757408", +"| c #60E804", +"1 c #927136", +"2 c #6D473C", +" ", +" ", +" ", +" ", +" ! - - ", +" ,(,,,) _ ", +" ],{#{,,,) ]:1 ", +" ,###%{{#,()(:: ", +" ###{###],,,(($1 ", +" ######,]]]!](;{ 1 ", +" %%##{{#,(;)*;;([[:_ ", +" %%%##{###,)*;;;(;::)- ", +" %%###%){,)))$^!);;:$;: ", +" %####{{]{]*[$^*];$$$;;$ ", +" -]%)####,,!!!{1!]];:;^;;$:{ ", +" -,,,({]]]##{,()){);;;$$:;$;1 ", +" +{,,,!,]*]!!]])(;;;)$22:*^[+ ", +" {,,!**:$!1^.2-2[:!^[%{):$[- ", +" {))$*--[[1.$.[;!;^$[[$$.[$1 ", +" {%)[$1-))[^[;;:;!:$22..*%11 ", +" {#)[{-;$22$!$;(;;;$[_22[::-+ ", +" #!(((2$.__.[$!!$$$$.$*)(:({+ ", +" }^*;$![.[!$!$$2...$::(;^}}1 ", +" #{_[[*21#}$$....^$$!2- ", +" },:11} }2..2+ __ _ ", +" ^.. ", +" }^^} ", +" '..' ", +" '.'''' ", +" _ ''.''''' + ", +" +++___''''_+++_+++ ", +" "}; diff --git a/src/Makefile.am b/src/Makefile.am index 4a8e2d6..d3d0396 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,6 +3,8 @@ AM_CFLAGS = -Wall -DLOCALEDIR=\"/usr/share/locale\" bin_PROGRAMS = fuser killall pstree +bin_SCRIPTS = pstree.x11 + fuser_SOURCES = fuser.c comm.h signals.c signals.h signames.h loop.h killall_SOURCES = killall.c comm.h signals.c signals.h signames.h @@ -15,7 +17,7 @@ pstree_LDADD = @TERMCAP_LIB@ @FLASK_LIB@ BUILT_SOURCES = signames.h -EXTRA_DIST = signames.c +EXTRA_DIST = signames.c pstree.x11 CLEANFILES = signames.h diff --git a/src/killall.c b/src/killall.c index 44402bf..4bc0850 100644 --- a/src/killall.c +++ b/src/killall.c @@ -64,99 +64,6 @@ ask (char *name, pid_t pid) return ch == 'y' || ch == 'Y'; } -#define MAX_PATHNAME (NAME_MAX * 2 + 14 + 1) -#define MAX_TESTPATH (NAME_MAX + 14 + 1) -int getuserprocs(int mysignal, int names, char **namelist) -{ - int i; - int j; - int waitpid = 0; - DIR *dir; - pid_t pidkilled; - pid_t* killedarray; - struct dirent *de; - char pathname[MAX_PATHNAME + 1]; - char testpath[MAX_TESTPATH + 1 ]; /* /proc//environ\0 15 chars */ - struct stat statbuf; - int maxnum = 100; - char answer; - - if(!namelist) exit(1); - if(!(killedarray = malloc( 100 * sizeof(pid_t) ))) - { - perror("malloc"); - exit(1); - } - for ( i = 0; i < names; i++) - { - if (exact) - { - for(j = 0; j < strlen(namelist[i]); j++) - { - if ( (namelist[i][j] == '*') || (namelist[i][j] =='?') ) - { - printf("Error, cannot match wildcards in exact mode\n"); - exit(1); - } - } - } - if (!(dir = opendir (PROC_BASE))) - { - perror (PROC_BASE); - exit (1); - } - while ( (de = readdir(dir)) != NULL) - { - snprintf(testpath, NAME_MAX+14, "/proc/%s/environ", de->d_name); - if (!stat(testpath, &statbuf) ) - { - if(S_ISREG(statbuf.st_mode) ) - { - sprintf(pathname, "cat /proc/%s/environ | grep LOGNAME=%s > /dev/null ", de->d_name, namelist[i]); - if ( system (pathname) == 0) - { - pidkilled = (pid_t)atoi(de->d_name); - killedarray[waitpid++] = pidkilled; - if ( waitpid == maxnum) - { - maxnum *= 2; - if (!(killedarray = realloc(killedarray, maxnum * sizeof(pid_t)))) - { - perror("realloc"); - exit(1); - } - } - } - } - } - } - } - closedir(dir); - for (i = 0; i < waitpid; i++) - { - if (interactive) - { - printf("Kill %d (y/n)?", (int)killedarray[i]); - scanf("%s", &answer); - } - if ( ( (interactive) && ( (answer == 'y') || (answer == 'Y') ) ) || !(interactive) ) - { - if(kill (process_group? -killedarray[i]: killedarray[i], mysignal ) == 0) - { - if(verbose) printf("Pid %d killed with signal %d\n", (int)killedarray[i], mysignal); - if(wait_until_dead) - { - kill(process_group? -killedarray[i]: killedarray[i], mysignal); - sleep(1); - } - - } - } - } - free(killedarray); - return 0; - -} #ifdef FLASK_LINUX static int kill_all(int signal, int names, char **namelist, security_id_t sid ) diff --git a/src/pstree.c b/src/pstree.c index 4e2f4fb..4b8a8e8 100644 --- a/src/pstree.c +++ b/src/pstree.c @@ -105,7 +105,7 @@ sym_ascii = static PROC *list = NULL; static int width[MAX_DEPTH], more[MAX_DEPTH]; static int print_args = 0, compact = 1, user_change = 0, pids = 0, by_pid = 0, - trunc = 1; + trunc = 1, wait_end = 0; #ifdef FLASK_LINUX static int show_sids = 0; static int show_scontext = 0; @@ -756,6 +756,7 @@ main (int argc, char **argv) pid_t pid, highlight; char termcap_area[1024]; int c; + char *tmpstr; if (ioctl (1, TIOCGWINSZ, &winsz) >= 0) if (winsz.ws_col) @@ -766,6 +767,13 @@ main (int argc, char **argv) setlocale(LC_ALL, ""); + if ( (tmpstr = strrchr(argv[0],'/'))) { + tmpstr++; + if (strcmp(tmpstr, "pstree.x11") ==0) + wait_end=1; + } + + #ifdef FLASK_LINUX while ((c = getopt (argc, argv, "acGhH:npluUVsx")) != EOF) #else /*FLASK_LINUX*/ @@ -874,5 +882,10 @@ main (int argc, char **argv) return 1; } } + if (wait_end == 1) { + fprintf(stderr, "Press return to close\n"); + (void)getchar(); + } + return 0; } diff --git a/src/pstree.x11 b/src/pstree.x11 new file mode 100755 index 0000000..03eb9fd Binary files /dev/null and b/src/pstree.x11 differ