Beispiel #1
0
void AtaTaskInit (void)
{
	KPRINTF ("AtaTaskInit()");

	ata_pid = GetPID();
	
	if ((ata_buffer = KMalloc (ATA_BUFFER_SZ)) != NULL)
	{
		if ((ata_timer_signal = AllocSignal()) != -1)
		{
			if ((ata_alarm_signal = AllocSignal()) != -1)
			{
				if ((ata_msgport = CreateMsgPort()) != NULL)
				{
					if (AtaInitUnits() == 0)
					{
						ata_init_error = 0;
						KSignal (GetPPID(), SIG_INIT);
						return;
					}
					
					DeleteMsgPort (ata_msgport);
				}
				
				FreeSignal (ata_alarm_signal);
			}

			FreeSignal (ata_timer_signal);
		}
				
		KFree (ata_buffer);
	}
	
	ata_init_error = -1;	
	KSignal (GetPPID(), SIG_INIT);
	
	Exit(-1);
}
/*
 * If SIGUSR1 was set to SIG_IGN when the server started, assume that either
 *
 *  a- The parent process is ignoring SIGUSR1
 *
 * or
 *
 *  b- The parent process is expecting a SIGUSR1
 *     when the server is ready to accept connections
 *
 * In the first case, the signal will be harmless, in the second case,
 * the signal will be quite useful.
 */
static void
InitParentProcess(void)
{
#if !defined(WIN32)
    OsSigHandlerPtr handler;
    handler = OsSignal (SIGUSR1, SIG_IGN);
    if ( handler == SIG_IGN)
	RunFromSmartParent = TRUE;
    OsSignal(SIGUSR1, handler);
    ParentProcess = getppid ();
#ifdef __UNIXOS2__
    /*
     * fg030505: under OS/2, xinit is not the parent process but
     * the "grant parent" process of the server because execvpe()
     * presents us an additional process number;
     * GetPPID(pid) is part of libemxfix
     */
    ParentProcess = GetPPID (ParentProcess);
#endif /* __UNIXOS2__ */
#endif
}
Beispiel #3
0
int
main()
{
    int x, y=6;

    PrintString("Parent PID: ");
    PrintInt(GetPID());
    PrintChar('\n');
    x = Fork();
    if (x == 0) {
       PrintString("Child PID: ");
       PrintInt(GetPID());
       PrintChar('\n');
       PrintString("Child's parent PID: ");
       PrintInt(GetPPID());
       PrintChar('\n');
       PrintString("Child calling sleep at time: ");
       PrintInt(GetTime());
       PrintChar('\n');
       Sleep(100);
       PrintString("Child returned from sleep at time: ");
       PrintInt(GetTime());
       PrintChar('\n');
       y++;
       PrintString("Child y=");
       PrintInt(y);
       PrintChar('\n');
       x = Fork();
       //Exec("../test/printtest");
       if (x == 0) {
          PrintString("Child PID: ");
          PrintInt(GetPID());
          PrintChar('\n');
          y++;
          PrintString("Child2 y=");
          PrintInt(y);
          PrintChar('\n');
          Exit(20);
       }
       else {
          PrintString("Parent after fork waiting for child: ");
          PrintInt(x);
          PrintChar('\n');
          PrintString("Parent2 join value: ");
          PrintInt(Join(x));
          PrintChar('\n');
          PrintString("Parent2 y=");
          PrintInt(y);
          PrintChar('\n');
          Exit(10);
       }
    }
    else {
       PrintString("Parent after fork waiting for child: ");
       PrintInt(x);
       PrintChar('\n');
       PrintString("Parent2 join value: ");
       PrintInt(Join(x));
       PrintChar('\n');
       PrintString("Parent y=");
       PrintInt(y);
       PrintChar('\n');
       Exit(1);
    }
    return 0;
}