0

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

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

谢谢。

4

1 回答 1

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);
    }
}
于 2013-09-27T03:36:02.913 回答