On Fri, Apr 23, 1999 at 05:16:33PM +0800, adr...@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]

-- 
Zach Heilig <z...@uffdaonline.net>


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

Reply via email to