Commit e2f4f861 authored by John P. Willis's avatar John P. Willis
Browse files

Further work on fmadm

parent 6aee218b
Pipeline #728 passed with stage
in 1 minute and 27 seconds
......@@ -64,6 +64,22 @@ int fma_jobs_list (int optc, char **opts)
return 0;
}
int fma_jobs_remove (int optc, char **opts)
{
int i;
pid_t job_pid;
for (i = 0; i < optc; i++) {
job_pid = atol (opts[i]);
kill (job_pid, SIGTERM);
}
return 0;
}
int fma_jobs_examine (int optc, char **opts)
{
long pids[FMA_MAXPID];
......
......@@ -129,6 +129,8 @@ int main (int argc, char **argv)
jobtab_init ();
job_init (TRUE);
fm_sig_init ();
/* go to fmadm shell if no arguments passed */
if (argc == 1) return fm_shell ();
......@@ -378,6 +380,7 @@ int fm_shell (void)
else if (strcmp (cmdt, "edit") == 0) cmd = FMAC_EDIT;
else if (strcmp (cmdt, "set") == 0) cmd = FMAC_SET;
else if (strcmp (cmdt, "show") == 0) cmd = FMAC_SHOW;
else if (strcmp (cmdt, "remove") == 0) cmd = FMAC_REMOVE;
else cmd = FMAC_INVALID;
i = 0;
......@@ -529,6 +532,22 @@ int fm_shell (void)
snprintf (fma_prompt, STRLEN - 1, "fmadm [%s]> ", fma_namespace);
}
else if (strcmp (args[0], "maintenance") == 0) {
if (strcmp (args[1], "on") == 0) {
shm_config->hdr->maintenance_mode = 1;
break;
}
else if (strcmp (args[1], "off") == 0) {
shm_config->hdr->maintenance_mode = 0;
break;
}
else {
printf ("fmadm: syntax error\n");
}
printf ("fmadm: syntax error\n");
}
else {
printf ("fmadm: syntax error\n");
......@@ -708,6 +727,9 @@ int fm_remove (short object, int optc, char **options)
switch (object) {
case OBJ_JOB:
return fma_jobs_remove (optc, options);
case OBJ_LOCK:
return fma_locks_remove (optc, options);
......@@ -1004,3 +1026,30 @@ void fm_write (FILE *file, char *buf)
{
fprintf (file, "%s\n", buf);
}
void fm_sig_attach (int sig, void *handler)
{
struct sigaction act;
act.sa_handler = handler;
sigaction (sig, &act, NULL);
}
void fm_sig_init (void)
{
sig_attach (SIGINT, &fm_on_sigint);
sig_attach (SIGTERM, &fm_on_sigterm);
}
void fm_on_sigint (void)
{
fprintf (stderr, "\nfmadm: caught SIGINT\n");
fmadm_exit ();
}
void fm_on_sigterm (void)
{
fprintf (stderr, "\nfmadm: caught SIGTERM\n");
fmadm_exit ();
}
......@@ -115,6 +115,11 @@ int fm_restore (short object, int optc, char **options);
int fm_migrate (short object, int optc, char **options);
int fm_edit (short object, int optc, char **options);
void fm_sig_attach (int sig, void *handler);
void fm_sig_init (void);
void fm_on_sigint (void);
void fm_on_sigterm (void);
extern char fma_namespace[STRLEN];
extern char fma_locktab[STRLEN];
extern char fma_routine_path[STRLEN];
......
......@@ -507,7 +507,7 @@ void job_dump(void)
if ((s->flags & JFLG_DEFUNCT) == JFLG_DEFUNCT) strcat (flag_s, "DEFUNCT ");
if ((s->flags & JFLG_REPLSENDER) == JFLG_REPLSENDER) strcat (flag_s, "REPLSENDER ");
if ((s->flags & JFLG_REPLRECEIVER) == JFLG_REPLRECEIVER) strcat (flag_s, "REPLRECEIVER ");
if ((s->flags & JFLG_FMADM) == JFLG_FMADM) strcat (flag_s, "FMADM");
if ((s->flags & JFLG_FMADM) == JFLG_FMADM) strcat (flag_s, "FMADM ");
if ((s->flags & JFLG_NEW) == JFLG_NEW) strcat (flag_s, "NEW ");
if ((s->flags & JFLG_DAEMON) == JFLG_DAEMON) strcat (flag_s, "DAEMON ");
......
......@@ -613,7 +613,7 @@ printf ("\r\nSTORE quack,foo neek\r\n");
for (slot = shm_config->hdr->jobtab_head; slot != NULL; slot = slot->next) {
if (slot->pid != pid) {
if ((slot->pid != pid) && ((slot->flags & JFLG_FMADM) != JFLG_FMADM)) {
kill (slot->pid, SIGINT);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment