Exemplo n.º 1
0
static void fault_test()
{
        int     status;

        (void) printf("-- fault test start\n");

        (void) printf("Fault test.  If this hangs, check your page fault handler...\n");
        (void) printf("Do you properly kill processes that segv?  ");
        if (!myfork()) {
                *(int *)0 = 0;
                exit(0);
        }

        if (wait(&status) == -1) {
                (void) printf("wait failed (errno=%d)\n", errno);
                exit(1);
        }

        /* This assumes that killing the process will set the status to
         * something other than 0
         */
        if (status) {
                (void) printf("yes\n");
        } else {
                (void) printf("no\n");
                exit(1);
        }

        (void) printf("-- fault test passed\n");
}
Exemplo n.º 2
0
static void cow_fork()
{
        int     status;
        int     foo = 0;

        (void) printf("-- COW fork test start\n");

        if (!myfork()) {
                /* We are in the child process, and should be accessing
                 * our own memory
                 */
                foo = 1;
                exit(0);
        }

        if (wait(&status) == -1) {
                (void) printf("wait failed (errno=%d)\n", errno);
                exit(1);
        }

        if (foo) {
                (void) printf("Data changed in child affected parent.\n"
                              "Make sure you mark writable private mappings copy-on-write.\n");
                (void) printf("Copy-on-write failed.\n");
                exit(1);
        }

        (void) printf("-- COW fork test passed\n");
}
Exemplo n.º 3
0
static void fork_test()
{
        (void) printf("-- Fork torture test start\n");

        (void) printf("The final test: forking up a storm.\n"
                      "If this doesn't crash your kernel, "
                      "you might be in good shape\n");
        (void) printf("(note that this is running in the background)\n");
        if (!myfork()) {
                for (;;) {
                        if (myfork()) {
                                exit(0);
                        }
                }
        }
}
Exemplo n.º 4
0
/*VARARGS1*/
int
execute(char *a, ...)	/* note: "exec" is already defined on u370 */
{
	va_list	ap;
	int	exitcode = -1;	/* initialize, to avoid warning */
	char	*argv[BUFSIZ];
	pid_t	p;

	/* fork and exec the program or shell script */
	endwin();	/* restore the terminal modes */
	mousecleanup();
	fflush(stdout);
	va_start(ap, a);
	for (p = 0; (argv[p] = va_arg(ap, char *)) != 0; p++)
		;
#if !HAVE_FORK
	/* HBB 20010313: in MSDOG, everything is completely different.
	 * No fork()/exec()/wait(), but rather a single libc call: */
        exitcode = spawnvp(P_WAIT, a, argv);
#else
	if ((p = myfork()) == 0) {
		myexecvp(a, argv);	/* child */
	}
	else {
		exitcode = join(p);	/* parent */
	}
#endif /* MSDOS */
	
	/* the menu and scrollbar may be changed by the command executed */
#if UNIXPC || !TERMINFO
# ifndef __DJGPP__ /* leave CRLF handling as is */      
	nonl();
# endif
	raw();	/* endwin() turns off cbreak mode so restore it */
	noecho();
#endif
	mousemenu();
	drawscrollbar(topline, nextline);
	va_end(ap);
	return(exitcode);
}
Exemplo n.º 5
0
Arquivo: t.c Projeto: B-Rich/CptS460
int body()
{
   char c, CR, buf[64],save;
   while(1){
      printf("=======================================\n");
      printQueue(readyQueue);      

      printf("proc %d %s in Kmode\n", running->pid, running->name);
      printf("input a command (s|f|u|q|i|o) : ");
      c=getc(); putc(c); save = c; CR=getc(); putc(CR);

      switch(save){
          case 's' : tswitch(); break;
          case 'u' : printf("\nProc %d ready to go U mode\n", running->pid);
                     goUmode(); break;
          case 'f':  myfork();  break;
          case 'q' : kexit();   break;
          case 'i' : iline();   break;
          case 'o' : oline();   break;
      }
   }
}
Exemplo n.º 6
0
void
main(int argc, char *argv[])
{
	char *p;
	int nout, nproc, status, i, c;

	thechar = '2';
	thestring = "68020";
	memset(debug, 0, sizeof(debug));
	cinit();
	outfile = 0;
	include[ninclude++] = ".";
	ARGBEGIN {
	default:
		c = ARGC();
		if(c >= 0 || c < sizeof(debug))
			debug[c] = 1;
		break;

	case 'o':
		outfile = ARGF();
		break;

	case 'D':
		p = ARGF();
		if(p)
			Dlist[nDlist++] = p;
		break;

	case 'I':
		p = ARGF();
		setinclude(p);
		break;
	} ARGEND
	if(*argv == 0) {
		print("usage: %ca [-options] file.s\n", thechar);
		errorexit();
	}
	if(argc > 1 && systemtype(Windows)){
		print("can't assemble multiple files on windows\n");
		errorexit();
	}
	if(argc > 1 && !systemtype(Windows)) {
		nproc = 1;
		if(p = getenv("NPROC"))
			nproc = atol(p);	/* */
		c = 0;
		nout = 0;
		for(;;) {
			while(nout < nproc && argc > 0) {
				i = myfork();
				if(i < 0) {
					i = mywait(&status);
					if(i < 0)
						errorexit();
					if(status)
						c++;
					nout--;
					continue;
				}
				if(i == 0) {
					print("%s:\n", *argv);
					if(assemble(*argv))
						errorexit();
					exits(0);
				}
				nout++;
				argc--;
				argv++;
			}
			i = mywait(&status);
			if(i < 0) {
				if(c)
					errorexit();
				exits(0);
			}
			if(status)
				c++;
			nout--;
		}
	}
	if(assemble(argv[0]))
		errorexit();
	exits(0);
}