Path: utzoo!attcan!utgpu!watmath!att!dptg!rutgers!cs.utexas.edu!uunet!mcsun!unido!ecrcvax!diomidis From: diomidis@ecrcvax.UUCP (Diomidis Spinellis) Newsgroups: comp.unix.wizards Subject: Re: Reading the symbol table of the currently running executable Summary: A method int eh 8th research eidtion of unix exists Message-ID: <777@ecrcvax.UUCP> Date: 21 Sep 89 10:09:36 GMT References: <9104@june.cs.washington.edu> <6131@lynx.UUCP> <920@aoa.UUCP> <1989Sep14.134546.2497@newcastle.ac.uk> Reply-To: diomidis@ecrcvax.UUCP (Diomidis Spinellis) Organization: ECRC, Munich 81, West Germany Lines: 38 In article <1989Sep14.134546.2497@newcastle.ac.uk> mccue@turing.newcastle.ac.uk (Dan McCue) writes: [...] > Are there other systems that provide a "system service" for finding > the (path)name/load map of the running executable(s)? The 8th Research Unix Edition provides a method of obtaining a file descriptor to the text file of a running executable. The idea is to open the image of the process in the process file system /proc and send the appropriate ioctl. #include #include /* * Return a read only file descriptor to the text file of an executable * given its process id. Returns -1 on failure. (Not tested). */ int pid2fd(pid) int pid; { static char fname[1024]; long result; int fd; sprintf(fname, "/proc/%d", pid); if ((fd = open(fname, 0)) == -1) return -1; if (ioctl(fd, PIOCOPENT, &result) == -1) return -1; return (int)result; } Diomidis -- Diomidis Spinellis European Computer-Industry Research Centre (ECRC) Arabellastrasse 17, D-8000 Muenchen 81, West Germany +49 (89) 92699199 USA: diomidis%ecrcvax.uucp@pyramid.pyramid.com ...!pyramid!ecrcvax!diomidis Europe: diomidis@ecrcvax.uucp ...!unido!ecrcvax!diomidis