mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* softdog doesn't work on 2.4.20-pre10?
@ 2002-10-09 14:07 Roy Sigurd Karlsbakk
  2002-10-09 14:40 ` Alan Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Roy Sigurd Karlsbakk @ 2002-10-09 14:07 UTC (permalink / raw)
  To: Kernel mailing list

[-- Attachment #1: Type: text/plain, Size: 462 bytes --]

hi

I have the softdog running on some of my machines, and I noticed it didn't 
work very well. I've got this little program feeding the dog (attached), so 
if it gets killed, the machine should reboot.

but - this doesn't happen!

can anyone take a look at this?

roy
-- 
Roy Sigurd Karlsbakk, Datavaktmester
ProntoTV AS - http://www.pronto.tv/
Tel: +47 9801 3356

Computers are like air conditioners.
They stop working when you open Windows.

[-- Attachment #2: feedthedog.c --]
[-- Type: text/x-csrc, Size: 1770 bytes --]

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <signal.h>
#include <syslog.h>
#include "watchdog.h"

#define TIMEOUT_DEFAULT 60

int fd;

void sig_any() {
	syslog(LOG_EMERG, "feedthedog killed by untrapped signal. System will be rebooted by watchdog.");
	exit(0);
}

void sig_term() {
	syslog(LOG_NOTICE, "Exiting, shutting down watchdog...");
	if (write(fd, "V", 1) == -1) {
		syslog(LOG_NOTICE, "Failed!");
		exit(1);
	}
	if (close(fd) == -1) {
		syslog(LOG_NOTICE, "Failed!");
		exit(1);
	}
	syslog(LOG_NOTICE, "Watchdog successfully shut down!");
	exit(0);
}

void get_info() {
	int timeout;
	struct watchdog_info info;

    ioctl(fd, WDIOC_GETTIMEOUT, &timeout);
    syslog(LOG_INFO, "Watchdog timeout is %d seconds\n", timeout);

	ioctl(fd, WDIOC_GETSUPPORT, &info);
	syslog(LOG_INFO, "Watchdog options: 0x%04x", info.options);
	syslog(LOG_INFO, "Watchdog firmware ver: %d", info.firmware_version);
	syslog(LOG_INFO, "Watchdog type:%s", info.identity);
}

int main() {
	int i,timeout;

	openlog("feedthedog", LOG_PID, LOG_DAEMON);

	if ((fd = open("/dev/watchdog", O_WRONLY)) == -1) {
		perror("open");
		exit(1);
	}

	timeout = atoi(getenv("WATCHDOG_TIMEOUT"));
	if (timeout <= 0) {
		syslog(LOG_WARNING, "Timeout set to %d. Using default.", timeout);
		timeout = TIMEOUT_DEFAULT;
	}

	get_info();
	for (i=1;i<=_NSIG;i++) {
		switch (i) {
			case SIGSTOP:
			case SIGKILL:
				break;
			case SIGTERM:
				signal(SIGTERM, sig_term);
				break;
			default:
				signal(i, sig_any);
				break;
		}
	}

	if (fork())
		exit(0);

	syslog(LOG_INFO, "Watchdog feeder started");

	while (1) {
		write(fd, "\0", 1);
		sleep(10);
	}

	return 0;
}

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: softdog doesn't work on 2.4.20-pre10?
  2002-10-09 14:07 softdog doesn't work on 2.4.20-pre10? Roy Sigurd Karlsbakk
@ 2002-10-09 14:40 ` Alan Cox
  2002-10-09 15:12   ` Roy Sigurd Karlsbakk
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Cox @ 2002-10-09 14:40 UTC (permalink / raw)
  To: Roy Sigurd Karlsbakk; +Cc: Linux Kernel Mailing List

On Wed, 2002-10-09 at 15:07, Roy Sigurd Karlsbakk wrote:
> hi
> 
> I have the softdog running on some of my machines, and I noticed it didn't 
> work very well. I've got this little program feeding the dog (attached), so 
> if it gets killed, the machine should reboot.

Make sure you have no way out set


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: softdog doesn't work on 2.4.20-pre10?
  2002-10-09 14:40 ` Alan Cox
@ 2002-10-09 15:12   ` Roy Sigurd Karlsbakk
  2002-10-09 15:33     ` Alan Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Roy Sigurd Karlsbakk @ 2002-10-09 15:12 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List

> > hi
> >
> > I have the softdog running on some of my machines, and I noticed it
> > didn't work very well. I've got this little program feeding the dog
> > (attached), so if it gets killed, the machine should reboot.
>
> Make sure you have no way out set

ok. works with no way out, but still...

When I killed 'feedthedog', I sent it a SIGKILL, so it couldn't have shut down 
the softdog properly.

roy

-- 
Roy Sigurd Karlsbakk, Datavaktmester
ProntoTV AS - http://www.pronto.tv/
Tel: +47 9801 3356

Computers are like air conditioners.
They stop working when you open Windows.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: softdog doesn't work on 2.4.20-pre10?
  2002-10-09 15:33     ` Alan Cox
@ 2002-10-09 15:27       ` Roy Sigurd Karlsbakk
  2002-10-09 15:46         ` Alan Cox
  0 siblings, 1 reply; 7+ messages in thread
From: Roy Sigurd Karlsbakk @ 2002-10-09 15:27 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List

On Wednesday 09 October 2002 17:33, Alan Cox wrote:
> On Wed, 2002-10-09 at 16:12, Roy Sigurd Karlsbakk wrote:
> > > > hi
> > > >
> > > > I have the softdog running on some of my machines, and I noticed it
> > > > didn't work very well. I've got this little program feeding the dog
> > > > (attached), so if it gets killed, the machine should reboot.
> > >
> > > Make sure you have no way out set
> >
> > ok. works with no way out, but still...
> >
> > When I killed 'feedthedog', I sent it a SIGKILL, so it couldn't have shut
> > down the softdog properly.
>
> Of course it did , it exited so the fil ehandles closed

not according to Documentation/watchdog-api.txt

but

it doesn't tell if the softdog supports the send-'V'-before-close-file command 
to shut it down

roy
-- 
Roy Sigurd Karlsbakk, Datavaktmester
ProntoTV AS - http://www.pronto.tv/
Tel: +47 9801 3356

Computers are like air conditioners.
They stop working when you open Windows.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: softdog doesn't work on 2.4.20-pre10?
  2002-10-09 15:12   ` Roy Sigurd Karlsbakk
@ 2002-10-09 15:33     ` Alan Cox
  2002-10-09 15:27       ` Roy Sigurd Karlsbakk
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Cox @ 2002-10-09 15:33 UTC (permalink / raw)
  To: Roy Sigurd Karlsbakk; +Cc: Linux Kernel Mailing List

On Wed, 2002-10-09 at 16:12, Roy Sigurd Karlsbakk wrote:
> > > hi
> > >
> > > I have the softdog running on some of my machines, and I noticed it
> > > didn't work very well. I've got this little program feeding the dog
> > > (attached), so if it gets killed, the machine should reboot.
> >
> > Make sure you have no way out set
> 
> ok. works with no way out, but still...
> 
> When I killed 'feedthedog', I sent it a SIGKILL, so it couldn't have shut down 
> the softdog properly.

Of course it did , it exited so the fil ehandles closed



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: softdog doesn't work on 2.4.20-pre10?
  2002-10-09 15:27       ` Roy Sigurd Karlsbakk
@ 2002-10-09 15:46         ` Alan Cox
  2002-10-09 15:58           ` Roy Sigurd Karlsbakk
  0 siblings, 1 reply; 7+ messages in thread
From: Alan Cox @ 2002-10-09 15:46 UTC (permalink / raw)
  To: Roy Sigurd Karlsbakk; +Cc: Linux Kernel Mailing List

On Wed, 2002-10-09 at 16:27, Roy Sigurd Karlsbakk wrote:
> it doesn't tell if the softdog supports the send-'V'-before-close-file command 
> to shut it down

That is a shutdown in no way out mode. In default mode when you close
the watchdog it stops


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: softdog doesn't work on 2.4.20-pre10?
  2002-10-09 15:46         ` Alan Cox
@ 2002-10-09 15:58           ` Roy Sigurd Karlsbakk
  0 siblings, 0 replies; 7+ messages in thread
From: Roy Sigurd Karlsbakk @ 2002-10-09 15:58 UTC (permalink / raw)
  To: Alan Cox; +Cc: Linux Kernel Mailing List

On Wednesday 09 October 2002 17:46, Alan Cox wrote:
> On Wed, 2002-10-09 at 16:27, Roy Sigurd Karlsbakk wrote:
> > it doesn't tell if the softdog supports the send-'V'-before-close-file
> > command to shut it down
>
> That is a shutdown in no way out mode. In default mode when you close
> the watchdog it stops

ok. so 'no way out' really means 'one way out'?

-- 
Roy Sigurd Karlsbakk, Datavaktmester
ProntoTV AS - http://www.pronto.tv/
Tel: +47 9801 3356

Computers are like air conditioners.
They stop working when you open Windows.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-10-09 15:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-09 14:07 softdog doesn't work on 2.4.20-pre10? Roy Sigurd Karlsbakk
2002-10-09 14:40 ` Alan Cox
2002-10-09 15:12   ` Roy Sigurd Karlsbakk
2002-10-09 15:33     ` Alan Cox
2002-10-09 15:27       ` Roy Sigurd Karlsbakk
2002-10-09 15:46         ` Alan Cox
2002-10-09 15:58           ` Roy Sigurd Karlsbakk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®