📄 spmchk.c
字号:
/* spmchk: see if there is a portmaster running on the specified machine * by attempting to open a Socket on it. If the attempt fails, return 1, * otherwise 0. * * XTDIO_USAGE: spmchk [machine] * * This can be used in a script like so: * * spmchk || Spm * * -or- * * spmchk || (nohup Spm > /dev/null)& * * to avoid having Spm print out an error message if it is already * running. * * Author: Marty Olevitch, Dec 1993 * (This routine is placed into the public domain.) */#include <stdio.h>#include <string.h>#include "sockets.h"/* --------------------------------------------------------------------- * Definitions: */#define BUFSIZE 256/* --------------------------------------------------------------------- * Prototypes: */#ifdef __PROTOTYPE__int main(int, char **);#elseextern main();#endif/* --------------------------------------------------------------------- * Source Code: */#ifdef __PROTOTYPE__int main( int argc, char **argv)#elseint main(argc, argv)int argc;char **argv;#endif{char hostnm[BUFSIZE];Socket *s;Sinit();if(argc > 1) strcpy(hostnm, argv[1]);else gethostname(hostnm,BUFSIZE);s = Sopen_clientport(hostnm, "PMClient", PORTMASTER);if (!s) { exit(2); }Sclose(s);#ifdef vmsexit(1);#elseexit(0);#endif}/* --------------------------------------------------------------------- */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -