|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 2010 (0x7da) Types: TextFile Notes: UNIX file Names: »HRCONSOLE.C«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code └─⟦2d53db1df⟧ UNIX Filesystem └─⟦this⟧ »hr/src/misc/HRCONSOLE.C«
#include <stdio.h> #include <signal.h> char HRIPC[] = "/drv/hripc", CLEAR[] = "/bin/sclear", DMGR[] = "/usr/hr/bin/dmgr", SMGR[] = "/usr/hr/bin/smgr", TEXT[] = "/usr/hr/bin/text", GMGR[] = "/usr/hr/bin/gmgr", CLOCK[] = "/usr/hr/bin/clock"; char *progs[] = { DMGR, SMGR, TEXT, GMGR, CLOCK }; char *pname[] = { "dmgr", "smgr", "text", "gmgr", "clock" }; int ppid[5]; main() { register int pid; register int i; int status; /* * Load the IPC driver */ pid = spawn("/dev/console", "/etc/load", "load", HRIPC, NULL); while (wait(&status) != pid) ; if (status != 0) exit(status); /* * Start all processes. Wait for the desktop to quit. */ for ( i=0 ; i < sizeof( progs )/sizeof( progs[0] ) ; i++ ) ppid[i] = spawn("/dev/console", progs[i] , pname[i], NULL); waitc(ppid[0]); for ( i=sizeof( progs )/sizeof( progs[0] ) - 1 ; i > 0 ; i-- ) { kill(ppid[i], SIGKILL); waitc(ppid[i]); } /* * Unload the IPC driver */ pid = spawn("/dev/console", "/etc/uload", "uload", HRIPC, NULL); while (wait(NULL) != pid) ; spawn("/dev/null", CLEAR, "clear", "w", NULL); } /* * Wait for the given process to complete. */ waitc(p1) register int p1; { register int p2; while ((p2=wait(NULL))>=0 && p2!=p1) ; } /* * Spawn off a command. */ spawn(tp, np, ap) char *tp; char *np; char *ap; { register int pid; register int fd; if ((pid=fork()) != 0) { if ( pid < 0 ) panic("Couldn't fork ", np); return (pid); } if ((fd=open(tp, 2)) < 0) panic("Cannot open ", tp, NULL); dup2(0, 1); dup2(0, 2); execv(np, &ap); panic("Cannot execute ", np, NULL); return (pid); } /* * Print out a list of error messages and exit. */ panic(cp) char *cp; { register char **cpp; close(0); open("/dev/console", 2); for (cpp=&cp; *cpp!=NULL; cpp++) printl(*cpp); printl("\n"); exit(0377); } /* * Print out a string on the standard output. */ printl(cp1) register char *cp1; { register char *cp2; for (cp2=cp1; *cp2; cp2++) ; write(0, cp1, cp2-cp1); }