我有进程名称,想检查进程是否在 HP NonStop OSS 中运行。我创建了小型 C 演示,但从 Guardian PROCESS_GETINFO_ 过程中得到错误。错误号是 3。下面是我的代码。你能告诉我有什么问题吗?
#include <cextdecs.h(PROCESS_GETINFO_)>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
short getProcess(const char*);
enum ZSYSValues
{
ZSYS_VAL_LEN_PROCESSDESCR = 33
} ;
int main() {
const char* processName = "myProcess";
short status = getProcess(processName);
printf("status = %d", status);
return 0;
}
short getProcess(const char* processName) {
short error = 9;
short length = 20;
short maxLength = ZSYS_VAL_LEN_PROCESSDESCR;
/* error: 0 - found; 4 - not found, otherwise - error*/
error = PROCESS_GETINFO_ ( /* *processhandle */
,(char*) processName
,maxLength
,&length
,/* *priority */
,/* *mom’s-processhandle */
,/* *hometerm */
,/* maxlen */
,/* *hometerm-len */
,/* *process-time */
,/* *creator-access-id */
,/* *process-access-id */
,/* *gmom’s-processhandle */
,/* *jobid */
,/* *program-file */
,/* maxlen */
,/* *program-len */
,/* *swap-file */
,/* maxlen */
,/* *swap-len */
,/* *error-detail */
,/* *proc-type */
,/* *oss-pid */
,/* timeout */ );
printf("error = %d", error);
switch(error) {
case 0: return 1; /* found */
case 4: return 0; /* not found */
}
return -1; /* error */
}