shutdown qnx6.x with C-code from user apps ?

hi all,
know anyone, how i can shutdown a qnx6.x system with c-code ?
i look for a sample like this for QNX4

thank you


/----------------------------------------------------------------------------/
static void shutdown(void)
{
struct sched_param param;
sigset_t bits;
union
{
struct _proc_shutdown s;
struct _proc_shutdown_reply r;
}msg;
qnx_sync(getnid());
bits=~0L;
sigprocmask(SIG_BLOCK,&bits,0);
msg.s.type=_PROC_SHUTDOWN;
msg.s.signum=SIGPWR;
Send(PROC_PID,&msg.s,&msg.r,sizeof(msg.s),sizeof(msg.r));
sleep(2);
param.sched_priority=PRIO_FIFO_MAX;
sched_setscheduler(0,SCHED_FIFO,&param);
}
/----------------------------------------------------------------------------/
void halt(void)
{
shutdown();
while(1)
Yield();
}
/----------------------------------------------------------------------------/
void reboot(void)
{
union
{
struct _proc_shutdown s;
struct _proc_shutdown_reply r;
}msg;
shutdown();
msg.s.type=_PROC_SHUTDOWN;
msg.s.signum=-1; // Restart
Send(PROC_PID,&msg.s,&msg.r,sizeof(msg.s),sizeof(msg.r));
}
/----------------------------------------------------------------------------/

Try using sysmgr_reboot(). However, this will not take care of cleanly
killing all the processes on the system. It simply reboots the machine.

chris


J?rg Hering <jhering@avecs-bergen.de> wrote:

hi all,
know anyone, how i can shutdown a qnx6.x system with c-code ?
i look for a sample like this for QNX4

thank you


/----------------------------------------------------------------------------/
static void shutdown(void)
{
struct sched_param param;
sigset_t bits;
union
{
struct _proc_shutdown s;
struct _proc_shutdown_reply r;
}msg;
qnx_sync(getnid());
bits=~0L;
sigprocmask(SIG_BLOCK,&bits,0);
msg.s.type=_PROC_SHUTDOWN;
msg.s.signum=SIGPWR;
Send(PROC_PID,&msg.s,&msg.r,sizeof(msg.s),sizeof(msg.r));
sleep(2);
param.sched_priority=PRIO_FIFO_MAX;
sched_setscheduler(0,SCHED_FIFO,&param);
}
/----------------------------------------------------------------------------/
void halt(void)
{
shutdown();
while(1)
Yield();
}
/----------------------------------------------------------------------------/
void reboot(void)
{
union
{
struct _proc_shutdown s;
struct _proc_shutdown_reply r;
}msg;
shutdown();
msg.s.type=_PROC_SHUTDOWN;
msg.s.signum=-1; // Restart
Send(PROC_PID,&msg.s,&msg.r,sizeof(msg.s),sizeof(msg.r));
}
/----------------------------------------------------------------------------/


Chris McKillop <cdm@qnx.com> “The faster I go, the behinder I get.”
Software Engineer, QSSL – Lewis Carroll –
http://qnx.wox.org/

“Chris McKillop” <cdm@qnx.com> wrote in message
news:bdsa60$ds3$1@nntp.qnx.com

Try using sysmgr_reboot(). However, this will not take care of cleanly
killing all the processes on the system. It simply reboots the machine.

chris

I.E. You may want to sund a message or a signal to your own processes so
they can flush out any data BEFORE the filesystem shuts down.

Hi Chris,
my favorite intention is halt the hole system
i will use this in a UPS- daemon …

thank you for the hints
greetings from Germanys biggest Island :slight_smile:



Chris McKillop wrote:

Try using sysmgr_reboot(). However, this will not take care of cleanly
killing all the processes on the system. It simply reboots the machine.

chris


J?rg Hering <> jhering@avecs-bergen.de> > wrote:


hi all,
know anyone, how i can shutdown a qnx6.x system with c-code ?
i look for a sample like this for QNX4

thank you


/----------------------------------------------------------------------------/
static void shutdown(void)
{
struct sched_param param;
sigset_t bits;
union
{
struct _proc_shutdown s;
struct _proc_shutdown_reply r;
}msg;
qnx_sync(getnid());
bits=~0L;
sigprocmask(SIG_BLOCK,&bits,0);
msg.s.type=_PROC_SHUTDOWN;
msg.s.signum=SIGPWR;
Send(PROC_PID,&msg.s,&msg.r,sizeof(msg.s),sizeof(msg.r));
sleep(2);
param.sched_priority=PRIO_FIFO_MAX;
sched_setscheduler(0,SCHED_FIFO,&param);
}
/----------------------------------------------------------------------------/
void halt(void)
{
shutdown();
while(1)
Yield();
}
/----------------------------------------------------------------------------/
void reboot(void)
{
union
{
struct _proc_shutdown s;
struct _proc_shutdown_reply r;
}msg;
shutdown();
msg.s.type=_PROC_SHUTDOWN;
msg.s.signum=-1; // Restart
Send(PROC_PID,&msg.s,&msg.r,sizeof(msg.s),sizeof(msg.r));
}
/----------------------------------------------------------------------------/



\


Joerg Hering
Chief Developer VDR
e-mail: jhering@avecs-bergen.de
privat: hering.ruegen@t-online.de
mobile: jhering.ruegen@gmx.de

AVECS Bergen GmbH
development department
Billrothstraße 11a
D-18528 Bergen auf Rügen

Tel.: +49 3838 2119101
Fax: +49 3838 2119105
Mobile: +49 172 3896974
URL: http://www.avecs-bergen.de