| Summary: | ps not annotatable in 4.0 | ||
|---|---|---|---|
| Product: | Base System | Reporter: | billh <billh> |
| Component: | bin | Assignee: | freebsd-bugs (Nobody) <bugs> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | Unspecified | ||
| Hardware: | Any | ||
| OS: | Any | ||
On Fri, Jun 09, 2000 at 08:04:19AM -0700, billh@europe.yahoo-inc.com wrote: > > create this C program, call it getargv.c, and compile with > cc -O -pipe getargv.c -lkvm -o getargv > [...] > > then compile and run the following (call it argv0.c, "make argv0") > > int main(int argc, char *argv[]) > { > argv[0] = "test"; > sleep(500); > return(0); > } > Try to setproctitle(3) in argv0(1). -- Ruslan Ermilov Oracle Developer/DBA, ru@sunbay.com Sunbay Software AG, ru@FreeBSD.org FreeBSD committer, +380.652.512.251 Simferopol, Ukraine http://www.FreeBSD.org The Power To Serve http://www.oracle.com Enabling The Information Age >then compile and run the following (call it argv0.c, "make argv0") > >int main(int argc, char *argv[]) >{ > argv[0] = "test"; > sleep(500); > return(0); >} Use setproctitle() -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD coreteam member | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. -On [20000609 20:01], billh@europe.yahoo-inc.com (billh@europe.yahoo-inc.com) wrote: > >>Description: >the kvm_getargv function returns the original argv passed to the >process, ignoring any changes that the process may have made to >ARGV, in conflict with the manual page. Which manual page are you referring to? kvm_getargv(3)? -- Jeroen Ruigrok vd Werven/Asmodai asmodai@[wxs.nl|bart.nl|freebsd.org] Documentation nutter/C-rated Coder BSD: Technical excellence at its best The BSD Programmer's Documentation Project <http://home.wxs.nl/~asmodai> Necessity relieves us of the ordeal of choice... State Changed
From-To: open->closed
On Mon, Jun 12, 2000 at 10:28:14AM +0100, Bill Hails wrote:
>
> Thanks very much for the info. We've just upgraded some of our boxes to
> 4.0 and man -k argv didn't show up setproctitle. My real problem is
> that in perl 5.6 assignment to $0 no longer has the desired effect,
> and some of our monitor code relies on it. I'll have to code something
> up with XS to tide us over.
|
the kvm_getargv function returns the original argv passed to the process, ignoring any changes that the process may have made to ARGV, in conflict with the manual page. How-To-Repeat: create this C program, call it getargv.c, and compile with cc -O -pipe getargv.c -lkvm -o getargv #include <fcntl.h> #include <kvm.h> #include <sys/param.h> #include <sys/user.h> #include <sys/sysctl.h> #include <stdio.h> int main(int argc, char *argv[]) { kvm_t *kd; kd = kvm_open(NULL, "/dev/mem", NULL, O_RDONLY, "kvm_open:"); if (kd != NULL) { int cnt; struct kinfo_proc *p = kvm_getprocs(kd, KERN_PROC_ALL, 0, &cnt); if (p != NULL) { int c; for (c = 0; c < cnt; ++c) { char **res = kvm_getargv(kd, p, 0); if (res) { while (*res) { printf("%s ", *res); res++; } printf("\n"); } else break; ++p; } } else { return(2); } kvm_close(kd); } else { return(1); } return(0); } then compile and run the following (call it argv0.c, "make argv0") int main(int argc, char *argv[]) { argv[0] = "test"; sleep(500); return(0); } in another window run the already compiled getargv as root. When I do this I see that the argv0 process has not had its ARGV[0] changed