Subject: Re: using "shutdown" as a shell
To: None <netbsd-help@netbsd.org>
From: Lubos Vrbka <shnek@chemi.muni.cz>
List: netbsd-help
Date: 09/12/2003 00:25:32
just to give the info about the program... it looks something like this 
(this is older version without the "debug" printouts)

lubos

===========================================================================================

#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h
#include <err.h>

#define TERMINAL "/dev/console"

int
main()
{
         char *tty = ttyname(0);
         int pid = fork();

         if(strncmp(tty, TERMINAL, strlen(TERMINAL)))
         {
                 fprintf(stderr, "Sorry, not at %s.\n", TERMINAL);
                 exit(0);
         }

         if(pid == -1) err(1, "shutup");
         if(pid)
         {
                 sleep(1000);
                 exit(0);
         }
         execlp("shutdown", "shutdown", "-r", "now", NULL);
         /* nebo -p nebo -h dle okolnosti */

         /* keep compiler from complaining: */
         return(0);
}

-- 
#####################################################
Mgr. Lubos Vrbka

Center for Complex Molecular Systems and Biomolecules
J. Heyrovsky Institute of Physical Chemistry
Academy of Sciences of the Czech Republic
Prague, Czech Republic

shnek@chemi.muni.cz
#####################################################