diff options
author | 2006-02-27 18:19:10 +0000 | |
---|---|---|
committer | 2006-02-27 18:19:10 +0000 | |
commit | 49f75a745bf1832eb180fbd9f90e3ca59e901edb (patch) | |
tree | 2c68d041b9e9827e7520ffa1b0ea4e39e1d820b9 /pspax.c | |
parent | - dont try to remove the execbits on a PT_LOAD section when using -Xe (diff) | |
download | pax-utils-49f75a745bf1832eb180fbd9f90e3ca59e901edb.tar.gz pax-utils-49f75a745bf1832eb180fbd9f90e3ca59e901edb.tar.bz2 pax-utils-49f75a745bf1832eb180fbd9f90e3ca59e901edb.zip |
- add support for named processes
Diffstat (limited to 'pspax.c')
-rw-r--r-- | pspax.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -21,7 +21,7 @@ #endif #define PROC_DIR "/proc" -static const char *rcsid = "$Id: pspax.c,v 1.27 2006/02/05 17:15:47 solar Exp $"; +static const char *rcsid = "$Id: pspax.c,v 1.28 2006/02/27 18:19:10 solar Exp $"; #define argv0 "pspax" @@ -204,7 +204,6 @@ static const char *get_proc_type(pid_t pid) return ret; } - static char *scanelf_file_phdr(elfobj *elf) { static char ret[8]; @@ -257,7 +256,7 @@ static const char *get_proc_phdr(pid_t pid) } -static void pspax(pid_t ppid) +static void pspax(pid_t ppid, const char *find_name) { register DIR *dir; register struct dirent *de; @@ -295,6 +294,12 @@ static void pspax(pid_t ppid) stat(de->d_name, &st); if ((errno != ENOENT) && (errno != EACCES)) { pid = (pid_t) atoi((char *) basename((char *) de->d_name)); + if (find_name && pid) { + char *str = get_proc_name(pid); + if (!str) continue; + if (strcmp(str, find_name) != 0) + pid = 0; + } if (((ppid > 0) && (pid != ppid)) || (!pid)) continue; @@ -420,6 +425,12 @@ static pid_t parseargs(int argc, char *argv[]) int main(int argc, char *argv[]) { - pspax(parseargs(argc, argv)); + pid_t pid = parseargs(argc, argv); + char *name = NULL; + + if ((optind < argc) && (pid == 0)) + name = argv[optind]; + + pspax(pid, name); return EXIT_SUCCESS; } |