Is there a way to see which process has a device open?

Primary tabs


I'm having trouble with a server printer where nobody can open a particular device. I've seen all over documentation that you can't open a device if another process already has it open, but I haven't been able to find out what process has a device opened already.

  • 0
  • 0
  • 125
  • 9
  • 3


You should check it in the OS, which you use. If it is a Linux, you can use the command lsof. For Windows, I don't know how to find it.

Is that the OS of the server with the printer on it, or the one with the database installed?

You may want to use some kind of print spooling to avoid the situations of monopolization such a device as printer. Take a look at CUPS; there is a brief notes how to use lp or lpr commands in Caché/IRIS: Using Pipes to Communicate with Processes.

On Windows we just used OS printer name for opening the device in Caché, and it was enough to spool the jobs to printer queue; no other tricks were needed.

Open devices for a process can be seen in the Processes section of the portal.  The initial process list shows the principal or current device and in the individual process page it shows all open devices, this can also be found using the %SYS.ProcessQuery OpenDevices
 method so you could write code that goes through all processes checking.

What these show may depend on how you open the device in the first place.


Thank you all for your responses. I might be in a different situation than I thought. I've gone through all the process looking for this device in open devices and I didn't find it, but any time I try to open the device it fails.

Is it possible for a device to get stuck open and cause the behavior I'm seeing?

Depends on the OS, you can also try to do the same outside of Caché, just to test it.

Could you tell us the OS and open command you are using, it might help with suggestions.

It's windows server 1012, the open command is O X::0, where X is the name of the device being opened

As this is a printer I assume X is "|PRN|printername_or_UNC" ?

If you can't see it open already then a failure to open can also indicate a problem with the printer.

We commonly get sites log an issue and it turns out they have changed UNC path/permissions, or the printer is offline/showing an error, and it is this which is the issue.

Yeah that's right about the format of X. When I try printing to that device from my test server it prints works fine. That's what made me think something is going on with my cache environment, or possibly something at the OS level like Dmitry mentioned.

Does the instance on the test server run with the same credentials as the production server, it could be permissions, also is the test server the same OS as some server versions are more strict if this is a shared printer on another machine.