在OpenVMS上从DCL命令行发送信号

时间:2013-03-25 17:30:00

标签: openvms dcl

我正在尝试通过OpenVMS服务器上的命令行发送信号。使用Perl我在进程之间设置了信号处理程序,而VMS上的Perl能够发送Posix信号。此外,C ++程序也能够发送和处理信号。但是,我遇到的问题是进程可能正在集群中的另一个节点上运行,我需要编写一个实用程序脚本来远程向它们发送信号。

我正在尝试避免编写新脚本,而只是简单地执行远程命令以从命令行发送信号。我需要发送SIGUSR1,它转换为OpenVMS的C $ _SIGUSR1。

感谢。

1 个答案:

答案 0 :(得分:1)

据我所知,没有支持的命令行界面来执行此操作。但是,您可以通过调用名为SYS $ SIGPRC()的未记录的系统服务来完成该任务。该系统服务可以为目标进程提供任何条件值,而不仅仅是POSIX信号。这是以标准格式描述的界面:

FORMAT

     SYS$SIGPRC process-id ,[process-name] ,condition-code

RETURNS

     OpenVMS usage: cond_value
     type:          longword (unsigned)
     access:        write only
     mechanism:     by value

ARGUMENTS

     process-id

     OpenVMS usage: process_id
     type:  longword (unsigned)
     access:    modify
     mechanism:     by reference

     Process identifier of the process for which is to receive the signal. The
     process-id argument is the address of an unsigned longword containing the
     process identifier. If you do not specify process-id, process-name is
     used.

     The process-id is updated to contain the process identifier actually
     used, which may be different from what you originally requested if you
     specified process-name.

     process-name

     OpenVMS usage: process_name
     type:          character string
     access:        read only
     mechanism:     by descriptor

     A 1 to 15 character string specifying the name of the process for
     which will receive the signal. The process-name argument is the
     address of a descriptor pointing to the process name string. The name
     must correspond exactly to the name of the process that is to receive
     the signal; SYS$SIGPRC does not allow trailing blanks or abbreviations.

     If you do not specify process-name, process-id is used. If you specify
     neither process-name nor process-id, the caller's process is used.
     Also, if you do not specify process-name and you specify zero for
     process-id, the caller's process is used.

     condition-value

     OpenVMS usage: cond_value
     type:          longword (unsigned)
     access:        read only
     mechanism:     by value

     OpenVMS 32-bit condition value. The condition-value argument is
     an unsigned longword that contains the condition value delivered
     to the process as a signal.

     CONDITION VALUES RETURNED

     SS$_NORMAL    The service completed successfully
     SS$_NONEXPR   Specified process does not exist
     SS$_NOPRIV    The process does not have the privilege to signal
                   the specified process
     SS$_IVLOGNAM  The process name string has a length of 0 or has
                   more than 15 characters
     (plus I suspect there are other possible returns having to do
      with various cluster communications issues)

EXAMPLE CODE

#include <stdio.h>
#include <stdlib.h>
#include <ssdef.h>
#include <stsdef.h>
#include <descrip.h>
#include <errnodef.h>
#include <lib$routines.h>

int main (int argc, char *argv[]) {
/*
**
** To build:
**
**      $ cc sigusr1
**      $ link sigusr1
**
** Run example:
**
**      $ sigusr1 := $dev:[dir]sigusr1.exe
**      $ sigusr1 20206E53
**
*/

static unsigned int pid;
static unsigned int r0_status;
extern unsigned int sys$sigprc (unsigned int *,
                                struct dsc$descriptor_s *,
                                int);

    if (argc < 2) {
        (void)fprintf (stderr, "Usage: %s PID\n",
                       argv[0]);
        exit (EXIT_SUCCESS);
    }

    sscanf (argv[1], "%x", &pid);

    r0_status = sys$sigprc (&pid, 0, C$_SIGUSR1);
    if (!$VMS_STATUS_SUCCESS (r0_status)) {
        (void)lib$signal (r0_status);
    }
}