![]() |
![]() HP OpenVMS Systemsask the wizard |
![]() |
The Question is: Hi... I've got an alpha running custom applications written in C (DEC C V5.7-004 on OpenVMS Alpha V7.1)(by myself and other developers). The applications are critical and run 7*24. Informational messages and alarms are written to log files via stdout. The way these detached process are run, it allows me to look/edit the log files while the programs are running, but alas, the files get large over a few weeks, and the editor takes a while to bring the files up or simply fails to bring them up. I would like to be able tell my program to close the log file (stdout) and re-open a new one. Alas, my attempts so far have ended up in a myriad of trials in file protections, none of which have clearly duplicated the implicit open that VMS or the CRTL stuffs into my code at link time. any thoughts? Thanks in advance Mike The Answer is : The OpenVMS Wizard would tend to use an I/O channel specifically for the log file, rather than stdout. This allows you to have full control over the behaviour of the log file. (Short of a process rundown and restart, there is no readily available way to switch a process log file.) For best control over file operations, the Wizard would tend to use RMS cakks directly. (Obviously, C can also certainly be directly used for file access. Native RMS calls provide much more direct control over the file-related activities, however.) To allow file sharing within C code, use options such as "shr=get" on the open -- see the documentation of creat for details -- and also remember to use the fsync and fflush calls at periodic intervals, as appropriate. A somewhat more unusual potential solution for your present application design -- one requiring fewer source modifications to your main applications -- would involve specifying the output device for the detached process as a mailbox, and creating a process that starts up before other applications, creates the necessary mailbox(es), and then reads the mailbox(es) and writes the contents of the messages to the file. In the longer term, the OpenVMS Wizard would tend to recommend the creation of a logging subsystem within the application, and writing binary (or binary and text format) messages into the logging subsystem for processing. Processing could include generating alarms when specific conditions arise, or simply formatting and writing various of the message to a log file. There are a variety of C programming examples -- including examples using mailboxes and RMS calls -- available on the OpenVMS Freeware V4.0 CD-ROM. Specifically, see the DISK$FREEWAREV4_2:[SRH_EXAMPLES] directory, among other directories.
|