#include "utility.h"
#include <stdlib.h>
#include <string.h>
#include "comm_data.h"
#include "comm_basics.h"
#include "comm_encode.h"
#include "general.h"
#include "gs_tools.h"
Go to the source code of this file.
Defines | |
#define | DIE_BAD_USAGE() |
Functions | |
int | main (int argc, char **argv) |
This program will ask the server to terminate. The usage is: GS_killserver <agent name>=""> <server name)
Definition in file gs_kill_server.c.
#define DIE_BAD_USAGE | ( | ) |
do { \ fprintf(stderr, "Usage: GS_killserver <agent name> <server name>\n"); \ fprintf(stderr, "Usage: GS_killserver -c <agent name> <server component id>\n"); \ exit(EXIT_FAILURE); \ } while(0)
Definition at line 22 of file gs_kill_server.c.
int main | ( | int | argc, | |
char ** | argv | |||
) |
Entry point for GS_killserver.
argc | -- arg count | |
argv | -- array of command line args |
Definition at line 39 of file gs_kill_server.c.
{ int agentport, by_cid; char *agent_name, *server_name; if((argc < 3) || (argc > 4)) DIE_BAD_USAGE(); agentport = getenv_int("GRIDSOLVE_AGENT_PORT", GRIDSOLVE_AGENT_PORT_DEFAULT); if(!strcmp(argv[1], "-c")) by_cid = 1; else by_cid = 0; if(argc == 3) { if(by_cid) DIE_BAD_USAGE(); else { agent_name = argv[1]; server_name = argv[2]; } } else { if(by_cid) { agent_name = argv[2]; server_name = (char *)malloc(strlen(argv[3]) + 2); if(!server_name) { fprintf(stderr, "failed to malloc memory\n"); exit(EXIT_FAILURE); } sprintf(server_name, "-c%s", argv[3]); } else DIE_BAD_USAGE(); } if(gs_kill_server(agent_name, agentport, server_name) < 0) { fprintf(stderr, "Failed to kill server %s\n", argv[3]); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }