From owner-freebsd-current Fri Apr 23 5:10: 8 1999 Delivered-To: freebsd-current@freebsd.org Received: from k6n1.znh.org (unknown [207.109.235.51]) by hub.freebsd.org (Postfix) with ESMTP id D1903151B1; Fri, 23 Apr 1999 05:09:31 -0700 (PDT) (envelope-from zach@uffdaonline.net) Received: (from zach@localhost) by k6n1.znh.org (8.9.3/8.9.1) id MAA78614; Fri, 23 Apr 1999 12:05:50 GMT (envelope-from zach) Date: Fri, 23 Apr 1999 07:05:49 -0500 From: Zach Heilig To: adrian@freebsd.org Cc: freebsd-current@freebsd.org Subject: Re: nice little kernel task for somebody Message-ID: <19990423070549.A78489@k6n1.znh.org> References: <9904221732.aa19138@salmon.maths.tcd.ie> <19990423091633.14103.qmail@ewok.creative.net.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.4i In-Reply-To: <19990423091633.14103.qmail@ewok.creative.net.au>; from adrian@freebsd.org on Fri, Apr 23, 1999 at 05:16:33PM +0800 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 #include #include #include 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] -- Zach Heilig To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message