add: void serverReady(bool flag) { writePid(flag); if (flag) checkMessage(); }  static void writePid (bool ready) { FILE* lck; char nlck[80]; sprintf (nlck, "/tmp/.kmail%d.lck", getuid()); lck = fopen (nlck, "w"); if (!ready) fprintf (lck, "%d", 0-getpid()); else fprintf (lck, "%d", getpid()); fclose (lck); }  static void checkMessage() { char lf[80]; sprintf (lf, "/tmp/.kmail%d.msg", getuid()); if (access(lf, F_OK) != 0) { printf ("No message for me\n"); return; } QString cmd; QString delcmd; cmd = kFileToString(lf); delcmd.sprintf("rm -rf /tmp/.kmail%d.msg", getuid()); system (delcmd.data());  KMMainWin *kmmWin = 0; if (kapp->topWidget() && kapp->topWidget()->isA("KMMainWin")) kmmWin = (KMMainWin *) kapp->topWidget();  if (cmd.find ("show") == 0) {  if (!kmmWin) { kmmWin = new KMMainWin; kmmWin->show(); } else KWM::activate(kmmWin->winId());   } else if (cmd.find ("check") == 0) {  if (!kmmWin) kmmWin = new KMMainWin; KWM::activate(kmmWin->winId());   kmmWin->slotCheckMail(); } else { int j; int i = cmd.find ("To: ", 0, true); if (i==-1) return;  QString to = ""; QString cc = ""; QString bcc = ""; QString subj = "";  j = cmd.find('\n', i); to = cmd.mid(i+4,j-i-4);  i = cmd.find ("Cc: ", j, true); if (i!=-1) { j = cmd.find('\n', i); cc= cmd.mid(i+4,j-i-4); }  i = cmd.find ("Bcc: ", j, true); if (i!=-1) { j = cmd.find('\n', i); bcc= cmd.mid(i+5,j-i-5); } i = cmd.find ("Subject: ", j, true); if (i!=-1) { j = cmd.find('\n', i); subj= cmd.mid(i+9,j-i-9); }    KMComposeWin* win; KMMessage* msg = new KMMessage;  msg->initHeader(); if (!cc.isEmpty()) msg->setCc(cc); if (!bcc.isEmpty()) msg->setBcc(bcc); if (!subj.isEmpty()) msg->setSubject(subj); if (!to.isEmpty()) msg->setTo(to);  win = new KMComposeWin(msg); assert(win != NULL); win->show(); }  }
context: static void setSignalHandler(void (*handler)(int));static void recoverDeadLetters(void);static void processArgs(int argc, char *argv[]);//-----------------------------------------------------------------------------// Message handlerstatic void kmailMsgHandler(QtMsgType aType, const char* aMsg){  QString appName = app->appName();  QString msg = aMsg;  msg.detach();  switch (aType)  {  case QtDebugMsg:    kdebug(KDEBUG_INFO, 0, msg);    break;  case QtWarningMsg:    fprintf(stderr, "%s: %s\n", (const char*)app->appName(), msg.data());    if (strncmp(aMsg,"KCharset:",9) != 0 &&	strncmp(aMsg,"QGManager:",10) != 0 &&	strncmp(aMsg,"QPainter:",9) != 0 &&	strncmp(aMsg,"Could not load", 14) != 0 &&	strncmp(aMsg,"QPixmap:",8) != 0)    {      KMsgBox::message(NULL, appName+" "+i18n("warning"), msg.data(),		       KMsgBox::EXCLAMATION);    }    else kdebug(KDEBUG_INFO, 0, msg);    break;  case QtFatalMsg:    fprintf(stderr, appName+" "+i18n("fatal error")+": %s\n", msg.data());    KMsgBox::message(NULL, appName+" "+i18n("fatal error"),		     aMsg, KMsgBox::STOP);    abort();  }}//-----------------------------------------------------------------------------// Crash recovery signal handlerstatic void signalHandler(int sigId){  QWidget* win;  fprintf(stderr, "*** KMail got signal %d\n", sigId);  // try to cleanup all windows  while (KTMainWindow::memberList->first() != NULL)  {    win = KTMainWindow::memberList->take();    if (win->inherits("KMComposeWin")) ((KMComposeWin*)win)->deadLetter();    delete win;  }  // If KMail crashes again below this line we consider the data lost :-|  // Otherwise KMail will end in an infinite loop.  setSignalHandler(SIG_DFL);  cleanup();  exit(1);}//-----------------------------------------------------------------------------static void setSignalHandler(void (*handler)(int)){  signal(SIGSEGV, handler);  signal(SIGKILL, handler);  signal(SIGTERM, handler);  signal(SIGHUP,  handler);  signal(SIGFPE,  handler);  signal(SIGABRT, handler);}