1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-29 02:50:28 +03:00

when scripts timeout, log pstree to a file in /tmp and just log the filename in the messages file

(This used to be ctdb commit 0785afba8e5cd501b9e0ecb4a6a44edf43b57ab0)
This commit is contained in:
Ronnie Sahlberg 2009-10-23 13:55:21 +11:00
parent 3c9b43531a
commit c61c655769

View File

@ -18,6 +18,7 @@
*/
#include "includes.h"
#include <time.h>
#include "system/filesys.h"
#include "system/wait.h"
#include "system/dir.h"
@ -36,36 +37,19 @@ static struct {
*/
static void sigterm(int sig)
{
FILE *p;
char tbuf[100], buf[200];
time_t t;
DEBUG(DEBUG_ERR,("Timed out running script '%s' after %.1f seconds pid :%d\n",
child_state.script_running, timeval_elapsed(&child_state.start), getpid()));
p = popen("pstree -p", "r");
if (p == NULL) {
DEBUG(DEBUG_ERR,("Failed popen to collect pstree for hung script\n"));
} else {
char buf[256];
int count;
t = time(NULL);
DEBUG(DEBUG_ERR,("PSTREE:\n"));
while(!feof(p)){
count=fread(buf, 1, 255, p);
if (count == EOF) {
break;
}
if (count < 0) {
break;
}
if (count == 0) {
break;
}
buf[count] = 0;
DEBUG(DEBUG_ERR,("%s", buf));
}
DEBUG(DEBUG_ERR,("END OF PSTREE OUTPUT\n"));
pclose(p);
}
strftime(tbuf, sizeof(tbuf)-1, "%Y%m%d%H%M%S", localtime(&t));
sprintf(buf, "pstree -p >/tmp/ctdb.event.%s.%d", tbuf, getpid());
system(buf);
DEBUG(DEBUG_ERR,("Logged timedout eventscript : %s\n", buf));
/* all the child processes will be running in the same process group */
kill(-getpgrp(), SIGKILL);