service stop <PID> : Catching this in a driver.
Hello!
What flag needs to be caught from a message's m_type when "service
stop" is called on your driver or other service? I tried looking at
some existing drivers and thought it was SYS_SIG, but that's apparently
only for shutdowns. Right now I have some code (see below) that just
catches non-HARD_INT messages in a "default" part of a case statement.
Any help would be appreciated so I can maybe streamline the types of
messages I catch before doing a shutdown of my service.
P.S.: The code must be built using GCC (g++). I know that may sound
odd to many of you, but it has something to do with the fact that I'm
writing a driver framework in C++ that has some additions the existing
framework doesn't have.
Thanks in advance.
++++++++++++++ BEGIN PASTE +++++++++++++++
#define _SYSTEM 1
#define _MINIX 1
#include <minix/config.h>
#include <ibm/interrupt.h>
#include <ansi.h>
#include <minix/type.h>
#include <minix/sysutil.h>
#include <minix/com.h>
#include <minix/ipc.h>
#include <minix/syslib.h>
#include <fstream>
#include <stdlib.h>
#include <unistd.h>
using namespace std;
static int i=0;
int main()
{
int irq=CLOCK_IRQ;
int id=irq+2;
int ret = sys_irqsetpolicy(irq, 0, &id);
if (ret) {
panic("PANICER", "error setting policy", ret);
}
ret = sys_irqenable(&id);
if (ret) {
panic("PANICER", "problem enabling interrupts", ret);
}
while (1) {
ofstream fout;
message m;
ret = receive(ANY, &m);
if (ret) {
panic("PANICER", "error receiving packet", ret);
}
switch(m.m_type) {
case HARD_INT:
ret = sys_irqenable(&id);
if (ret) {
panic("PANICER", "problem enabling interrupts", ret);
}
fout.open("/tmp/panicer.out");
fout << ++i << '\n';
fout.close();
break;
default:
ret = sys_irqrmpolicy(irq, &id);
if (ret) {
panic("PANICER", "problem removing policy", ret);
}
}
}
return 0;
}
Re: service stop <PID> : Catching this in a driver.
*Bumping back onto list.*