2013-03-25 45 views
0

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

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

谢谢。

回答

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); 
    } 
}