Example #1
0
main()
{
system("date");
    pid_t pid;
    int rv;
    time_t ltime;

    int i = 0;
 	for (i = 0; i< 40; i++)
	{
    	switch(pid=fork()) {
        	case -1:
        		perror("fork");  /* something went wrong */
        		exit(1);         /* parent exits */
        	case 0:
			keyGenerator(i, 2048);
		    	printf("CHILD: I'm finished here! %d\n", getpid() );
			system("date");		    	
			exit(rv);
        	default:
				if(i == 2) 
				{
			    	printf("PARENT: About to quit!\n");
				}
		}
	}
}
Example #2
0
void OtrInternal::create_privkey(const char *accountname,
                                 const char *protocol)
{
    Q_ASSERT(m_userstate);

    if(!m_mutex.tryLock(10))
        return;

    QMessageBox warnBox(QMessageBox::Warning,tr("qutim-otr"),tr("Key generation will be started.<br>Please, make sure that you <b>log out from all your jabber accounts</b>! QutIM may be crashed if they will be online while key is generating."),QMessageBox::Ok,NULL,Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
    warnBox.setModal(false);
    warnBox.setWindowModality(Qt::NonModal);
    warnBox.setDefaultButton(QMessageBox::Ok);
    warnBox.show();
    warnBox.setEscapeButton(QMessageBox::Cancel);
    while(!warnBox.isHidden())
        QCoreApplication::processEvents();

    QMessageBox infoMb(QMessageBox::Information, tr("qutim-otr"),
                       tr("Generating keys for account %1\nThis may take a while.\nPlease, move mouse and use keyoard to decrease generation time.").arg(QString(accountname)),
                       QMessageBox::Ok, NULL,
                       Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
    infoMb.button(QMessageBox::Ok)->setEnabled(false);
    infoMb.button(QMessageBox::Ok)->setText(tr("please wait..."));
    infoMb.setWindowModality(Qt::NonModal);
    infoMb.setModal(false);
    infoMb.show();
    {
        KeyGeneratorThread keyGenerator(m_userstate, m_keysFile,
                                                                  accountname, protocol);
        keyGenerator.start();

        while (!keyGenerator.isFinished())
            QCoreApplication::processEvents();
    }
    m_mutex.unlock();
    infoMb.button(QMessageBox::Ok)->setEnabled(true);
    infoMb.button(QMessageBox::Ok)->setText("Ok");

    char fingerprint[45];
    if (otrl_privkey_fingerprint(m_userstate, fingerprint, accountname,
                                 protocol) == NULL)
    {
        QMessageBox failMb(QMessageBox::Critical, tr("qutim-otr"),
                           tr("Failed to generate key for account %1\nThe OTR Plugin will not work.").arg(QString(accountname)),
                           QMessageBox::Ok, NULL,
                           Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
        failMb.exec();
    }
    else
    {
        infoMb.setText(tr("The fingerprint for account %1 is\n").arg(QString(accountname)) + QString(fingerprint));
    }
    infoMb.exec();

}