void ToSend(char *str, int len, server_cb_inf *inf) { int curlen; if (inf->servinf->curstring == NULL) { inf->servinf->curstring=(char *)calloc(len+1, sizeof(char)); if(inf->servinf->curstring==NULL) { #ifdef DEBUG perror("malloc"); #endif DO_SYSL("not enough memory!") kill_thread(inf); /*NOTREACHED*/ } strncpy(inf->servinf->curstring, str, len); } else { curlen=strlen(inf->servinf->curstring); inf->servinf->curstring=(char *)realloc(inf->servinf->curstring, curlen+len+1); if(inf->servinf->curstring==NULL) { DO_SYSL("not enough memory!") onxxdebug("memory low, disconnecting child and killing the child process.\n"); kill_thread(inf); /*NOTREACHED*/ } strncpy(inf->servinf->curstring + curlen, str, len); inf->servinf->curstring[curlen+len]='\0'; } }
CAMLprim value win_kill_threads (value fd) { CAMLparam1(fd); if (Field(fd, 1) != Val_long(0)) { kill_thread((HANDLE *) &Field(Field(fd, 1), READ)); kill_thread((HANDLE *) &Field(Field(fd, 1), WRITE)); } CAMLreturn(Val_unit); }
void GenesisCopyWindow::Copy(const char *filename, const char *destination, const char *destfilename) //////////////////////////////////////////////////////////////////////// { BEntry sourcefile(filename); BString text; if (sourcefile.InitCheck()==B_OK) { /* BString text; text.SetTo(""); text << filename << "\n" << destination; BAlert *myAlert = new BAlert("Copy debug",text.String(),"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); myAlert->Go(); */ if (sourcefile.IsDirectory()) { if (IsRecursiveCopy(filename, destination)) { BString text; text << "Recursive copy not allowed.\nPlease check the destination folder."; BAlert *myAlert = new BAlert("Copy",text.String(),"OK", NULL, NULL, B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT); myAlert->Go(); Close(); kill_thread(m_CopyThread); } CopyDirectory(filename, destination, destfilename); } else if (sourcefile.IsSymLink()) CopyLink(filename,destination, destfilename); else CopyFile(filename, destination, destfilename); } else if (!m_SkipAllCopyError) { text << "Error while initializing file:\n\n" << filename; BAlert *myAlert = new BAlert("Copy",text.String(),"Abort","Skip all","Skip",B_WIDTH_AS_USUAL,B_OFFSET_SPACING,B_WARNING_ALERT); myAlert->SetShortcut(0, B_ESCAPE); switch (myAlert->Go()) { case 0: Close(); kill_thread(m_CopyThread); break; case 1: m_SkipAllCopyError = true; break; } } }
void stopproxy(void) { thread_id tid; status_t r; kill_thread(tid_proxy); wait_for_thread(tid_proxy,&r); for(;;){ tid=find_thread("Charisma/serveclient"); if(tid<0) break; kill_thread(tid); wait_for_thread(tid,&r); } }
void catching() { thread_h tid = thread_spawn("bsh echo Testing if bsh catches SIGINT..."); if (tid == INVALID_THREAD) { fprintf(stderr, "Failed to spawn thread\n"); abort(); } delay(); if (kill((int)tid, SIGINT) != 0) { fprintf(stderr, "Failed to send SIGINT\n"); abort(); } delay(); if (!is_thread_running(tid)) { fprintf(stderr, "Thread did not catch signal\n"); abort(); } delay(); kill_thread(tid, SIGKILL); }
void VUView::_Quit() { fQuitting = true; snooze(10000); kill_thread(fThreadId); }
TFTPClient::~TFTPClient() { this->Disconnect(); if (fReceiverThreadID >= B_OK) kill_thread(fReceiverThreadID); delete fReplyBuff; if (fSemID >= B_OK) delete_sem(fSemID); }
void free_thread_info(struct thread_info *ti) { struct thread_exit_info *ei = ti->exit_info; kfree(ti); kill_thread(ei); }
int main() { // Test program to reproduce bug #2562. Is finished quickly and must be run // in a loop to reproduce the bug. // install signal handler if (signal(SIGUSR1, signal_handler) == SIG_ERR) { fprintf(stderr, "Error: Failed to install signal handler: %s\n", strerror(errno)); exit(1); } // start signal thread thread_id signalThread = spawn_thread(&signal_pusher, "signal pusher", B_NORMAL_PRIORITY, NULL); resume_thread(signalThread); allocator_thread(0); kill_thread(signalThread); snooze(1000); printf("test successful, handled %lld signals\n", sHandledSignals); return 0; }
bool MessageLooper::Run() { BAutolock locker(this); fQuitting = false; char name[B_OS_NAME_LENGTH]; _GetLooperName(name, sizeof(name)); // Spawn our message-monitoring thread fThread = spawn_thread(_message_thread, name, B_DISPLAY_PRIORITY, this); if (fThread < B_OK) { fQuitting = true; return false; } if (resume_thread(fThread) != B_OK) { fQuitting = true; kill_thread(fThread); fThread = -1; return false; } return true; }
HTGTimeLineView::~HTGTimeLineView() { /*Kill the update thread*/ if(previousThread != B_NAME_NOT_FOUND) kill_thread(previousThread); listView->RemoveSelf(); while(!listView->IsEmpty()) { HTGTweetItem *currentItem = (HTGTweetItem *)listView->FirstItem(); listView->RemoveItem(currentItem); if(currentItem->getTweetPtr() != NULL) currentItem->getTweetPtr()->setView(NULL); delete currentItem; } delete listView; while(!unhandledList->IsEmpty()) { HTGTweetItem *currentItem = (HTGTweetItem *)unhandledList->FirstItem(); unhandledList->RemoveItem(currentItem); if(currentItem->getTweetPtr() != NULL) currentItem->getTweetPtr()->setView(NULL); delete currentItem; } delete unhandledList; if(twitObj != NULL) delete twitObj; if(!IsReplicant()) { theScrollView->RemoveSelf(); delete theScrollView; } }
void WaitWindow::MessageReceived(BMessage* msg) { switch (msg->what) { case 'canc': { kill_thread(fStateThreadID); kill_thread(fParentID); Quit(); break; } default: { BWindow::MessageReceived(msg); break; } } }
/* FUNCTION: Video :: ~Video ARGUMENTS: n/a RETURN: n/a DESCRIPTION: Destructor */ Video :: ~Video() { if (fVideoThread > 0) kill_thread(fVideoThread); delete fMediaFile; delete fBitmap; }
void test_kill_thread() { int vthr; printf("spawn victim thread 1\n"); vthr = spawn_thread(victim1, "victim", 0, 16); sleep(250000); kill_thread(vthr); printf("killed it\n"); printf("spawn victim thread 2\n"); vthr = spawn_thread(victim2, "victim", 0, 16); sleep(250000); kill_thread(vthr); printf("killed it\n"); }
PRIVATE void setup_context(int task_no, int max) /* setup the thread context */ { char c; if (setjmp(thread_table[task_no].context)) { if (DEBUG_LEVEL >= 2) { printf("Starting now thread %d\n", task_no); } kernel_mode=NO; thread_table[task_no].start_function(); /* if the thread reaches this point it is actually exiting; kill it */ if (DEBUG_LEVEL > 0) printf("Thread %d exhausts\n", task_no); kill_thread(task_no); } else { /* Pass to create next task */ if (DEBUG_LEVEL >= 1) printf("Thread %d created\n", task_no); thread_table[task_no].stack_start = &c; allocate_stack(task_no+1, max); /* this never returns...*/ } }
/* call a request handler */ static void call_req_handler( struct thread *thread ) { union generic_reply reply; enum request req = thread->req.request_header.req; current = thread; current->reply_size = 0; clear_error(); memset( &reply, 0, sizeof(reply) ); if (debug_level) trace_request(); if (req < REQ_NB_REQUESTS) req_handlers[req]( ¤t->req, &reply ); else set_error( STATUS_NOT_IMPLEMENTED ); if (current) { if (current->reply_fd) { reply.reply_header.error = current->error; reply.reply_header.reply_size = current->reply_size; if (debug_level) trace_reply( req, &reply ); send_reply( &reply ); } else { current->exit_code = 1; kill_thread( current, 1 ); /* no way to continue without reply fd */ } } current = NULL; }
BubbleHelper::~BubbleHelper() { if(helperthread>=0) { // force helper thread into a known state bool locked=textwin->Lock(); // Be rude... kill_thread(helperthread); // dispose of window if(locked) { textwin->PostMessage(B_QUIT_REQUESTED); textwin->Unlock(); } } if(helplist) { helppair *pair; int i=helplist->CountItems()-1; while(i>=0) { pair=(helppair*)helplist->RemoveItem(i); if(pair && pair->text) free(pair->text); delete pair; i--; } delete helplist; } atomic_add(&runcount,-1); }
//--------------------------------------------------------------------- // MessageReceived //--------------------------------------------------------------------- // // Receive messages // void TMIDICue::MessageReceived(BMessage* message) { switch(message->what) { case B_OK: case B_REFS_RECEIVED: { fPanel->Hide(); // Attempt to load MIDI file if ( LoadMIDIFile(message) ) Init(); } break; case MIDI_PLAYBACK_DONE_MSG: { fSynthFile->Fade(); fSynthFile->Stop(); fSynthFile->UnloadFile(); fIsPlaying = false; kill_thread(fPlaybackThread); fPlaybackThread = NULL; } break; default: TCueView::MessageReceived(message); break; } }
static void docmd_group(char *cmdstring, server_cb_inf *inf) { char *ptr; char *sql_cmd; ptr = get_slinearg(cmdstring, 1); if (!ptr) { ToSend(no_group_given, strlen(no_group_given), inf); return; /* let him try again */ } if ((sql_cmd = (char *)calloc(strlen(cmdstring) + 0x7f, sizeof(char))) == NULL) { DO_SYSL("GROUP: not enough memory.") free(ptr); kill_thread(inf); /*NOTREACHED*/ } snprintf(sql_cmd, strlen(cmdstring) + 0x7f, "select * from newsgroups where name='%s';", ptr); /* the cb func sets found_group to '1' if the group is found */ inf->servinf->found_group = 0; sqlite3_secexec(inf, sql_cmd, docmd_group_cb, inf); free(ptr); free(sql_cmd); /* if the group was not found (=the cb function was not called) ... */ if (inf->servinf->found_group == 0) { /* send "no such group" */ ToSend(nosuchgroup, strlen(nosuchgroup), inf); } return; }
WrapWindow::~WrapWindow() { kill_thread(draw_thread_id); ah_player->Stop(); Object_delete((Object*)context); Object_delete((Object*)ah_list); }
void Ticker::Stop() { if (fTicker) { kill_thread(fTicker); fTicker = 0; } }
void InfoBox::ExitUpdateThread() { if (suspend_thread(update_Thread)!=B_BAD_THREAD_ID) { //send_data(update_Thread, 'exit', NULL, 0); kill_thread(update_Thread); //acquire_sem(exit_thread_sem); } ut_running=false; }
~SpinnerPrivateData(void) { if (fRepeaterID != -1) { fExitRepeater = false; kill_thread(fRepeaterID); } }
//------------------------------------------------------------------------------ BMenuField::~BMenuField() { if (fLabel) free(fLabel); if (fMenuTaskID >= 0) kill_thread(fMenuTaskID); }
int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "Usage:\n %s <filename>\n", argv[0]); return 1; } entry_ref ref; if (get_ref_for_path(argv[1], &ref)!=B_OK) return 2; BMediaFile *playFile = new BMediaFile(&ref); if (playFile->InitCheck()<B_OK) { delete playFile; return 2; } for (int ix=0; ix<playFile->CountTracks(); ix++) { BMediaTrack * track = playFile->TrackAt(ix); playFormat.type = B_MEDIA_RAW_AUDIO; if ((track->DecodedFormat(&playFormat) == B_OK) && (playFormat.type == B_MEDIA_RAW_AUDIO)) { playTrack = track; break; } if (track) playFile->ReleaseTrack(track); } // Good relations with the Wookiees, I have. signal(SIGINT, keyb_int); new BApplication("application/x-vnd.Antares-playfile"); finished = create_sem(0, "finish wait"); printf("playing file...\n"); // Execute Plan 66! sp = new BSoundPlayer(&playFormat.u.raw_audio, "playfile", play_buffer); sp->SetVolume(1.0f); // Join me, Padmé and together we can rule this galaxy. sp->SetHasData(true); sp->Start(); acquire_sem(finished); if (interrupt) { // Once more, the Sith will rule the galaxy. printf("interrupted\n"); sp->Stop(); kill_thread(reader); } printf("playback finished\n"); delete sp; delete playFile; }
void cs_reinit_clients(struct s_auth *new_accounts) { struct s_auth *account; unsigned char md5tmp[MD5_DIGEST_LENGTH]; struct s_client *cl; for (cl = first_client->next; cl; cl = cl->next) { if ((cl->typ == 'c' || cl->typ == 'm') && cl->account) { for (account = new_accounts; (account) ; account = account->next) { if (!strcmp(cl->account->usr, account->usr)) break; } if (account && !account->disabled && cl->pcrc == crc32(0L, MD5((uchar *)ESTR(account->pwd), strlen(ESTR(account->pwd)), md5tmp), MD5_DIGEST_LENGTH)) { cl->account = account; if (cl->typ == 'c') { cl->grp = account->grp; cl->aureader_list = account->aureader_list; cl->autoau = account->autoau; cl->expirationdate = account->expirationdate; cl->allowedtimeframe[0] = account->allowedtimeframe[0]; cl->allowedtimeframe[1] = account->allowedtimeframe[1]; cl->ncd_keepalive = account->ncd_keepalive; cl->c35_suppresscmd08 = account->c35_suppresscmd08; cl->tosleep = (60*account->tosleep); cl->c35_sleepsend = account->c35_sleepsend; cl->monlvl = account->monlvl; cl->disabled = account->disabled; cl->fchid = account->fchid; // CHID filters cl->cltab = account->cltab; // Class // newcamd module doesn't like ident reloading if (!cl->ncd_server) cl->ftab = account->ftab; // Ident cl->sidtabs.ok = account->sidtabs.ok; // services cl->sidtabs.no = account->sidtabs.no; // services cl->failban = account->failban; memcpy(&cl->ctab, &account->ctab, sizeof(cl->ctab)); memcpy(&cl->ttab, &account->ttab, sizeof(cl->ttab)); webif_client_reset_lastresponsetime(cl); if (account->uniq) cs_fake_client(cl, account->usr, (account->uniq == 1 || account->uniq == 2) ? account->uniq + 2 : account->uniq, cl->ip); ac_init_client(cl, account); } } else { if (get_module(cl)->type & MOD_CONN_NET) { cs_debug_mask(D_TRACE, "client '%s', thread=%8lX not found in db (or password changed)", cl->account->usr, (unsigned long)cl->thread); kill_thread(cl); } else { cl->account = first_client->account; } } } else { cl->account = NULL; } } }
status_t HTGTimeLineView::Archive(BMessage* archive, bool deep) const { /*Kill the update thread*/ if(previousThread != B_NAME_NOT_FOUND) kill_thread(previousThread); status_t status = BView::Archive(archive, deep); if(status == B_OK) status = archive->AddString("add_on", "application/x-vnd.HaikuTwitter"); if(status == B_OK) status = archive->AddString("class", "HTGTimeLineView"); /*Archive ivars*/ if(status == B_OK) status = archive->AddBool("HTGTimeLineView::waitingForUpdate", waitingForUpdate); if(status == B_OK) status = archive->AddBool("HTGTimeLineView::wantsNotifications", wantsNotifications); if(status == B_OK) status = archive->AddBool("HTGTimeLineView::saveTweets", saveTweets); if(status == B_OK) status = archive->AddInt32("HTGTimeLineView::searchID", searchID); if(status == B_OK) status = archive->AddInt32("HTGTimeLineView::TYPE", TYPE); if(status == B_OK) status = archive->AddString("HTGTimeLineView::name", Name()); /*Archive login information*/ std::string tokenSecret; twitObj->getOAuth().getOAuthTokenSecret(tokenSecret); if(status == B_OK) status = archive->AddString("HTGTimeLineView::oauthSecret", tokenSecret.c_str()); std::string tokenKey; twitObj->getOAuth().getOAuthTokenKey(tokenKey); if(status == B_OK) status = archive->AddString("HTGTimeLineView::oauthKey", tokenKey.c_str()); if(deep) { BMessage listViewArchive; if(listView->Archive(&listViewArchive, deep) == B_OK) { if(status == B_OK) status = archive->AddMessage("HTGTimeLineView::listView", &listViewArchive); } BMessage unhandled; HTGTweetItem* currentItem; for(int i = 0; i < unhandledList->CountItems(); i++) { currentItem = (HTGTweetItem* )(unhandledList->ItemAt(i)); if(currentItem->Archive(&unhandled, deep) == B_OK) { if(status == B_OK) status = archive->AddMessage("HTGTimeLineView::unhandled", &unhandled); } } } return status; }
// destructor ColorSlider::~ColorSlider() { if (fUpdatePort) delete_port(fUpdatePort); if (fUpdateThread) kill_thread(fUpdateThread); delete fBgBitmap; }
/* FUNCTION: MainWindow :: ~MainWindow ARGUMENTS: n/a RETURN: n/a DESCRIPTION: Destructor */ MainWindow :: ~MainWindow() { kill_thread(fAnimationThreadID); RemoveChild(fCurrentView); delete fCurrentView; sMainWindowCount--; if (sMainWindowCount == 0) be_app->PostMessage(B_QUIT_REQUESTED); }
void learnView::Start() { if (frameTID >= 0) kill_thread(frameTID); if (mSpace == 0) return; mFrame = 0; // start a thread to increment the frame frameTID = spawn_thread((thread_entry)frameThread, "frameThread", B_NORMAL_PRIORITY, this); resume_thread(frameTID); }