void CreateProc(struct ProcessHandle *infoPtr) { infoPtr->pid = fork(); if (infoPtr->pid < 0) { printf("Error with creating process."); return; } else if (infoPtr->pid == 0) { sleep(5); printf("\nChild process created.\n"); printf("Child process PID = %d", getpid()); printf("\nChild process will be killed after 10 seconds.\n"); sleep(1); PrintCurrentTime(); } else { printf("Parent process created.\n"); printf("Parent process PID = %d\n", getpid()); PrintCurrentTime(); } return; }
void * IRReceiver::ReadEvent() { ssize_t readRet = 1; unsigned char buf[TEMP_BUF_LENGTH] = {0}; unsigned int curKey; bool isKeypad; bool isLowercase; unsigned char modifier = 0; int unicode= -1; qWarning("SoftIR: read from pipe"); readRet = read( m_fd, (void*)buf, (size_t)IR_MESSAGE_LENGTH ); if ( readRet > 0 ) { bool checkForDrop; // buf holds device, number //fprintf(stderr, "SoftIR: %x %x %x (%d)\n", buf[0], buf[1],buf[2], readRet); curKey = INVALID_KEY; if (buf[0] == NRD_QT_KEY) { modifier = buf[1]; curKey = buf[2]; unicode = buf[3]; isKeypad = false; checkForDrop = false; } else { // remove toggle bit for table lookup buf[1] &= 0x7F; //fprintf(stderr,"Original input 0x%x \n",buf[2]); isLowercase = ( (buf[2]>0x60) & (buf[2] < 0x7B) ); curKey = keymap()->value(buf[2]); // set key value to invalid key code if (curKey != 0) { // send key up to framework PrintCurrentTime(); //fprintf(stderr, "SoftIR: sending key = 0x%x\n", (int)curKey); if (buf[0] == NRD_PIC_GTV_KEY) { //fprintf(stderr,"GTV key 0x%x, mo %x lowercase %d\n",curKey,buf[1],isLowercase); modifier = buf[1]; } unicode = QtCodeToUnicode(curKey,isLowercase); } checkForDrop = true; } // timeb tb; // ftime(&tb); // int nCount = tb.millitm + (tb.time & 0xfffff) * 1000; // fprintf(stderr, "FromSoftIR: sending unicode = 0x%x keycode = 0x%x modifier=0x%x at %d\n", (int)unicode, (int)curKey, (int)modifier,nCount); SendKey((int)curKey, unicode, modifier, checkForDrop); } else if (readRet == 0) { qWarning("SoftIR: pipe EOF"); cleanUp(0); } else { qWarning("SoftIR: read error from pipe"); cleanUp(-1); } return NULL; }