Xref: utzoo comp.unix.questions:28204 comp.unix.internals:1862 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!bria!mike Newsgroups: comp.unix.questions,comp.unix.internals Subject: Re: how to determine if a process has access to tty ports Message-ID: <385@bria> Date: 23 Jan 91 09:50:26 GMT References: <6763@fs1.cam.nist.gov> Reply-To: bria!mike (Michael Stefanik) Followup-To: comp.unix.questions Organization: Briareus Corporation, Los Angeles, CA Lines: 20 In article <6763@fs1.cam.nist.gov> cam.nist.gov!coleman (Sean Sheridan Coleman X5672) writes: :I want to be able to determine if another process has control :of an RS232 port on a Alm Board on a Sun4. I am writing a :program to gather data from a device that is connected via :RS-232. I want to deny access to the program if another program :is accessing the port currently. If you're worried about login processes, you could read /etc/utmp (but if this is a special device, I doubt that's the case); the slicker solution would be to read the namelist in /unix, and look through the proc table. A similar (but considerably slower) solution would be to popen() ps -t ttyxx and see if there is anything attached to it. If you're looking for any process that has simply done an open() on the port, though, that's another story. -- Michael Stefanik, Systems Engineer (JOAT), 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 ..."