Changeset 2211 for trunk/auto-reply
- Timestamp:
- 08/17/00 07:02:25 (8 years ago)
- Location:
- trunk/auto-reply
- Files:
-
- 3 modified
-
licq_autoreply.conf (modified) (1 diff)
-
src/autoreply.cpp (modified) (6 diffs)
-
src/autoreply.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/auto-reply/licq_autoreply.conf
r2204 r2211 23 23 PassMessage = 0 24 24 25 # If this is set, then the exit code of the command will 26 # be used to determine if the message should be sent or 27 # not. A non-zero code will cause the reply to be aborted. 28 FailOnExitCode = 0 29 30 # This value is used if the above is set and the exit code 31 # is non zero. If set then a bad exit code will not delete 32 # the relevant message. If not set then the event will be 33 # erased even if the command exit code is non-zero. 34 AbortDeleteOnExitCode = 1 35 25 36 26 37 # Here is a simple example which will bounce the event -
trunk/auto-reply/src/autoreply.cpp
r2204 r2211 85 85 conf.ReadStr("Arguments", m_szArguments, ""); 86 86 conf.ReadBool("PassMessage", m_bPassMessage, false); 87 conf.ReadBool("FailOnExitCode", m_bFailOnExitCode, false); 88 conf.ReadBool("AbortDeleteOnExitCode", m_bAbortDeleteOnExitCode, false); 87 89 conf.CloseFile(); 88 90 … … 286 288 m_szMessage[pos++] = c; 287 289 } 288 PClose(); 290 int r = 0; 291 if ((r = PClose()) != 0 && m_bFailOnExitCode) 292 { 293 gLog.Warn("%s%s returned abnormally: exit code %d\n", L_AUTOREPxSTR, 294 szCommand, r); 295 return !m_bAbortDeleteOnExitCode; 296 } 289 297 290 298 char *szText = new char[4096 + 256]; … … 367 375 368 376 369 voidCLicqAutoReply::PClose()377 int CLicqAutoReply::PClose() 370 378 { 371 379 int r, pstat; 380 struct timeval tv = { 0, 200000 }; 372 381 373 382 // Close the file descriptors … … 379 388 r = waitpid(pid, &pstat, WNOHANG); 380 389 // Return if child has exited or there was an inor 381 if (r == pid || r == -1) return;390 if (r == pid || r == -1) goto pclose_done; 382 391 383 392 // Give the process another .2 seconds to die 384 struct timeval tv = { 0, 200000 };385 393 select(0, NULL, NULL, NULL, &tv); 386 394 387 395 // Still there? 388 396 r = waitpid(pid, &pstat, WNOHANG); 389 if (r == pid || r == -1) return;397 if (r == pid || r == -1) goto pclose_done; 390 398 391 399 // Try and kill the process 392 if (kill(pid, SIGTERM) == -1) return ;400 if (kill(pid, SIGTERM) == -1) return -1; 393 401 394 402 // Give it 1 more second to die … … 399 407 // See if the child is still there 400 408 r = waitpid(pid, &pstat, WNOHANG); 401 if (r == pid || r == -1) return;409 if (r == pid || r == -1) goto pclose_done; 402 410 403 411 // Kill the bastard … … 405 413 // Now he will die for sure 406 414 waitpid(pid, &pstat, 0); 407 } 408 409 415 416 pclose_done: 417 418 if (WIFEXITED(pstat)) return WEXITSTATUS(pstat); 419 return -1; 420 421 } 422 423 -
trunk/auto-reply/src/autoreply.h
r2204 r2211 27 27 char *m_szStatus; 28 28 char m_szProgram[512], m_szArguments[512]; 29 bool m_bPassMessage ;29 bool m_bPassMessage, m_bFailOnExitCode, m_bAbortDeleteOnExitCode; 30 30 31 31 CICQDaemon *licqDaemon; … … 41 41 42 42 bool POpen(const char *cmd); 43 voidPClose();43 int PClose(); 44 44 45 45 protected:
