Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Apr 1999 20:31:07 +0800
From:      adrian@freebsd.org
To:        Zach Heilig <zach@uffdaonline.net>
Cc:        freebsd-current@freebsd.org
Subject:   Re: nice little kernel task for somebody 
Message-ID:  <19990423123108.14692.qmail@ewok.creative.net.au>
In-Reply-To: Your message of "Fri, 23 Apr 1999 07:05:49 EST." <19990423070549.A78489@k6n1.znh.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
Zach Heilig writes:
>On Fri, Apr 23, 1999 at 05:16:33PM +0800, adrian@freebsd.org wrote:
>> I don't know about that one, but the first one sounds easish.
>> Since I've been messing around with procfs quite a bit lately,
>> I'll spend some time later today poking around and produce a patch
>> against -current .
>
>I don't know how to do this, but I did notice this much: (the binary does
>remain accessible even after it's removed, as long as it doesn't exit).
>
>#include <sys/types.h>
>#include <stdio.h>
>#include <stdlib.h>
>#include <unistd.h>
>
>int main(int argc, char **argv) {
>  int id;
>  char cmd[128];
>  unlink(argv[0]);
>  id = getpid();
>  printf("pid == %d\n", id);
>  sprintf(cmd, "ls -l /proc/%d", id);
>  system(cmd);
>  exit(0);
>}
>
>$ cc foo.c
>$ ./a.out
>pid == 78597
>total 4
>-r--r--r--  1 zach  wheel     0 Apr 23 07:00 cmdline
>--w-------  1 zach  wheel     0 Apr 23 07:00 ctl
>-r--r--r--  1 zach  wheel    76 Apr 23 07:00 etype
>-rwxrwxr-x  0 zach  wheel  3637 Apr 23 07:00 file
>-rw-------  1 zach  wheel   176 Apr 23 07:00 fpregs
>-r--r--r--  1 zach  wheel    76 Apr 23 07:00 map
>-rw-r-----  1 zach  kmem      0 Apr 23 07:00 mem
>--w-------  1 zach  wheel     0 Apr 23 07:00 note
>--w-------  1 zach  wheel     0 Apr 23 07:00 notepg
>-rw-------  1 zach  wheel    76 Apr 23 07:00 regs
>-r--r--r--  1 zach  wheel     0 Apr 23 07:00 status
>$ 
>
>[note the '0' links for the binary]
>

Which is right though, isn't it?


I've finished the patch. I'll test it a little more when I get back
home tonight, and then send the URL to -current for people to poke
around with.

phk - I hope you didn't also want the process limits to be modifyable
the same way just yet :-) (but it'd be nice however... maybe later.)



Adrian


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990423123108.14692.qmail>