Xref: utzoo comp.unix.questions:28334 comp.unix.admin:918 comp.unix.internals:1927 comp.unix.programmer:949 comp.unix.misc:887 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bria!mike Newsgroups: comp.unix.questions,comp.unix.admin,comp.unix.internals,comp.unix.programmer,comp.unix.misc Subject: Re: How determine if a file is opened by another process Keywords: file open Message-ID: <406@bria> Date: 31 Jan 91 00:45:30 GMT References: <1488@nixsin.UUCP> <1991Jan29.204403.6071@rick.doc.ca> Reply-To: uunet!bria!mike (Michael Stefanik) Followup-To: comp.unix.questions Organization: Briareus Corporation, Los Angeles, CA Lines: 28 In an article, calvin.doc.ca!andrew (Andrew Patrick) writes: >I need to know if there's a standard, *safe* way for a process to >find out if some other process (any other process on the machine) >has a specific file open at the time of the query. [...] >Oh yes. The machine is an Encore Multimax 520, running UMax V (a >System V based UNIX-alike). I do know about the dodge of reading >/dev/kmem, and the Multimax has a special call to get the address of >the inode table, to make it a little safer, but I'd like to avoid >this. The program which needs this info would then have to be >setuid root, or /dev/kmem would have to be opened for general read >access, which we want to avoid if at all possible. There is no portable way to get the information that you want; poking through the kernel is the only way I know of determining if some unrelated and/or non-cooperative process has a file open. If you're worried about security issues (as well you should be), then one solution would be to write a SUID daemon that, when prodded, will dump this information into shared memory. Thus, the program itself need not be running in a privileged state. However, the point remains, any mucking about such as this is inherently non-portable. -- Michael Stefanik | Opinions stated are not even my own. Systems Engineer, Briareus Corporation | UUCP: ...!uunet!bria!mike ------------------------------------------------------------------------------- technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly found to be saying things like "Well, it works on my DOS machine ..."