Skip to main content Logo (IEC resistor symbol)logo

Quis custodiet ipsos custodes?
Home | About | All pages | RSS Feed | Gopher

File locking, grep and process killing on OpenVMS

Published: 06-05-2018 | Author: Remy van Elst | Text only version of this article

Table of Contents


(You can read all my OpenVMS articles by clicking the picture above)

On the DECUS OpenVMS system there is no curl or wget installed. Iwanted to download a remote C file to play around with the compiler and somesimple Hello World code, to get a feel of the build system. After a bit ofsearching around the internet I was not able to find a command like curl or wgetto download a remote file. But, the searches led me to the OpenVMS port of curl,which, I hoped, might be able to run on the DECUS system. Just like on a linuxsystem, running the binary under my user account, not install it system wide.This ended up to be another adventure in which I figured out how to trace alocked file to a process, grep the output of a process on OpenVMS and kill aprocess. I did not get curl to work or compile my code, yet.

If you like this article, consider sponsoring me by trying out a Digital OceanVPS. With this link you'll get $100 credit for 60 days). (referral link)

The cc command is installed on the DECUS system:

$ CC /VERSIONHP C V7.3-010 on OpenVMS Alpha V8.4-2L2

When I get to my C code I will probably play around and write another smallarticle on it here.

I downloaded the OpenVMS curl version from the vmsports project to mycomputer. This is a project that compiles some software for OpenVMS, likefind, python and the one I was looking for, curl.

Using an sFTP client (filezilla), I uploaded the file to the DECUS system.You're all probably thinking, why did he not just upload his C code with sFTP?It simply did not occur, yet. When I was typing this article I thought, hmm. Butit was too late already, plus, I did learn new stuff in the process. As Bob Rosswould say, We don't make mistakes, just happy little accidents.

Filezilla however did complain and kept uploading the file. I closed Filezillaand went to check what was wrong via SSH. The file was there, leaving 5versions. Probably an upload failure. Delete the files and try again.

-RMS-E-FLK, file currently locked by another user

I found out how to remove files and folders and wrote an article on that.To remove all versions of a file, using big scary wildcards:

$ DELETE vmsports*.*;*%DELETE-W-FILNOTDEL, error deleting DSA3:[DECUSERVE_USER.EXAMPLE]VMSPORTS-AXPVMS-83-CURL-V0747--1.ZIP;1-RMS-E-FLK, file currently locked by another user

Huh? I was not aware of multiple users or sessions in this account.

That error message refers to the RMS. I saw that here as well, I mightneed to look into it some more.

I remembered something about locking when reading HELP pages earlier. In thiscase, I tried the following:


That didn't help. Lets read the HELP:

$ HELP SET FILE /UNLOCKSET  FILE    /UNLOCK       Clears a file marked as deaccess locked. Deaccess locking is       required by and used by those few applications that maintain       their own locking and consistency, typically without the use       of the OpenVMS distributed lock manager, and potentially also       without the use of RMS. When an application using deaccess       locking does not correctly deaccess the file (often due to an       application or system failure), the file is marked as locked, and       is thus inaccessible until the integrity of the contents of the       file are verified and the SET FILE/UNLOCK command is used.       This command does not affect the state of files that are locked       using RMS or the distributed lock manager.       For details on file deaccess locking, see the VSI OpenVMS I/O       User's Reference Manual, the ACP-QIO interface documentation, and       specifically the FIB$V_DLOCK option available on the IO$_CREATE       and IO$_ACCESS functions.       The SET FILE/UNLOCK command can clear the cause of the following       error message:       %SYSTEM-W-FILELOCKED, file is deaccess locked       However, this command cannot resolve the cause of the error       message:       %RMS-W-FLK, file currently locked by another user

That explains why it did not work. I suspected that there might be a processwhich locked my file.

Tracing a process' open files (lsof)

The HPe forums where of help here. First I needed the root disk name, which isin the DIR output:

$ DIRDirectory DSA3:[DECUSERVE_USER.EXAMPLE]$MAIN.TPU$JOURNAL;1 .VIMINFO;1          A.;1                FTP_SERVER.LOG;3FTP_SERVER.LOG;1    LOGIN.COM;2         LOGIN.COM;1         LOGIN_COM.TPU$JOURNAL;1MAIL.DIR;1          NOTES$NOTEBOOK.NOTE;1                   SSH.DIR;1SSH2.DIR;1          THREE.DIR;1         VMSPORTS-AXPVMS-83-CURL-V0747--1.ZIP;1WWW.DIR;1

Using the SHOW DEV command we can list all processes that have files open:

$ SHOW DEV /FILES DSA3:Files accessed on device DSA3: on  6-MAY-2018 10:31:44.88Process name      PID     File name                00000000  insufficient privilege or object protection violation                00000000  insufficient privilege or object protection violationRob Brooks      0000043B  insufficient privilege or object protection violationHENKLE          0000F62B  insufficient privilege or object protection violationHENKLE          0000F62B  insufficient privilege or object protection violationHENKLE          0000F62B  insufficient privilege or object protection violationHENKLE          0000F62B  insufficient privilege or object protection violation[...]HtHTNOTES_AN165 0000E541  insufficient privilege or object protection violation<FTP_EXAMPLE>      00011591  [DECUSERVE_USER.EXAMPLE]FTP_SERVER.LOG;3<FTP_EXAMPLE>      00011591  [DECUSERVE_USER.EXAMPLE]VMSPORTS-AXPVMS-83-CURL-V0747--1.ZIP;1

Except for the huge list of errors, it confirms that the FTP server has lockedmy file. One of the ways to release that lock is to stop the process. Anotherway is to reboot the system. The latter being a harsh solution if all elsefails.

Search the output of one command for a string (pipe and grep) on OpenVMS

A big list of open files is not really usefull, and I don't want to see allthose other users, none of my business. I wanted to filter that list to onlyshow my user. Let's see if I can use a pipe and grep:

$ SHOW DEV /FILES DSA3: | GREP EXAMPLE%DCL-W-MAXPARM, too many parameters - reenter command with fewer parameters \|\

Nope, but I do suspect OpenVMS having an excellent solution for this problem.The DCL shell is over 30 years old so someone had to have this problem.

Browsing around the documentation I found this. It seems that if you wantto pipe output of a command, you first need to preface the command with the wordPIPE, then the command, then the | (pipe char), then another process.

There is no grep on OpenVMS unless you install it. There however is SEARCH.A logical name, just like most of OpenVMS' workings.

The search command requires a filename. You can't just pipe output into itdirectly, you need to tell it that it has to search the output. OpenVMS has theSYS$OUTPUT and SYS$INPUT files for that when using the PIPE command.

Reading through the documentation:

A few tries later I conjured up this command sequence:

$ PIPE SHOW DEV /FILES DSA3: | SEARCH SYS$INPUT EXAMPLEFiles accessed on device DSA3: on  6-MAY-2018 12:48:11.51Process name      PID     File name[...]<FTP_EXAMPLE>      000111AF  [DECUSERVE_USER.EXAMPLE]FTP_SERVER.LOG;4

To show all running processes including their PID's, use the SHOW SYSTEMcommand. Combine that with out PIPE&SEARCH shell trick to get all theprocesses of the current user. Searching the docs didn't gave me anotherway or flag to the SHOW SYSTEM or SHOW PROCESS command to filter out onespecific user.

$ PIPE SHOW SYSTEM | SEARCH SYS$INPUT EXAMPLEOpenVMS V8.4-2L2  on node EISNER    6-MAY-2018 12:49:45.02   Uptime  23 18:27:17  Pid    Process Name    State  Pri      I/O       CPU       Page flts  Pages[...]0001156B EXAMPLE            LEF      9      374   0 00:00:00.15       641     89000111AF <FTP_EXAMPLE>      LEF      5    46299   0 00:00:06.01       705    346  N000115B0 EXAMPLE_62273      LEF      6      129   0 00:00:00.01        84    105  S000115BE EXAMPLE_27501      CUR   0  4      188   0 00:00:00.04       138    165  S000115BF EXAMPLE_29010      COM      4      185   0 00:00:00.02       128    152  S

It seems that we can try to stop (kill) process 000111AF. Use the STOPcommand with the /ID flag:

$ STOP /ID=000111AF

Now the file deletion was possible:

$ DEL VMSPO*.*;*$

The actual cause of the upload failure? I don't have enough quota.


The sFTP client showed me this error after failing a few times:

550 File Write Error: %%SYSTEM-F-EXDISKQUOTA, disk quota exceeded

This is where my adventure ends. Without looking up documentation, because ofthe logicalness of DCL, the following command showed me that I had exhausted mydisk quota:

$ show quota  User [EXAMPLE] has 10000 blocks used, 0 available,  of 10000 authorized and permitted overdraft of 0 blocks on DISK_USER

What is a disk block you ask? Again the documentation has all the answers:

A disk block is the minimum unit of disk storage allocation in OpenVMS.Under OpenVMS VAX and OpenVMS Alpha, the disk volume block size is consistent, with each block containing 512 bytes, or one-half kilobyte. Each byte is comprised of eight bits. A bit represents the smallest unit of information, typically refered to as a one or a zero.[...]The number of bytes in a file can be determined by multiplying the number of blocks allocated for the file times the number of bytes in a block. For example: to convert OpenVMS disk blocks to (base two) kilobytes (KB; 1024 bytes), simply divide by two. To convert blocks to (base two) megabytes, divide by 2048. Blocks to (base two) gigabytes (GB), divide by 2097152. 

In the case of the DECUS system, I have about 5 megabytes of quota and my zippedcurl was around 7 MB, explaining the quota error.

Tags: alpha, blog, dec, decus, es40, itanium, openvms, pdp, simh, vax, vms