ngircd.patch 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. Index: src/ngircd/ngircd.c
  2. --- src/ngircd/ngircd.c.orig 2005-01-26 23:09:33 +0100
  3. +++ src/ngircd/ngircd.c 2005-03-16 13:15:05 +0100
  4. @@ -77,6 +77,9 @@
  5. #ifdef SNIFFER
  6. NGIRCd_Sniffer = FALSE;
  7. #endif
  8. +#ifdef PID_FILE
  9. + strlcpy( NGIRCd_PidFile, "/dev/null", sizeof( NGIRCd_PidFile ));
  10. +#endif
  11. strlcpy( NGIRCd_ConfFile, SYSCONFDIR, sizeof( NGIRCd_ConfFile ));
  12. strlcat( NGIRCd_ConfFile, CONFIG_FILE, sizeof( NGIRCd_ConfFile ));
  13. @@ -139,6 +142,19 @@
  14. Show_Version( );
  15. exit( 1 );
  16. }
  17. +#ifdef PID_FILE
  18. + if( strcmp( argv[i], "--pidfile" ) == 0 )
  19. + {
  20. + if( i + 1 < argc )
  21. + {
  22. + /* Ok, there's an parameter left */
  23. + strlcpy( NGIRCd_PidFile, argv[i + 1], sizeof( NGIRCd_PidFile ));
  24. +
  25. + /* next parameter */
  26. + i++; ok = TRUE;
  27. + }
  28. + }
  29. +#endif
  30. }
  31. else if(( argv[i][0] == '-' ) && ( argv[i][1] != '-' ))
  32. {
  33. @@ -282,6 +298,21 @@
  34. /* Child-Prozess initialisieren */
  35. (VOID)setsid( );
  36. +#ifdef PID_FILE
  37. + {
  38. + mode_t old_umask;
  39. + pid_t pid;
  40. + FILE *fp;
  41. +
  42. + old_umask = umask((mode_t) 0022);
  43. + pid = getpid();
  44. + if ((fp = fopen(NGIRCd_PidFile, "w")) == NULL)
  45. + syslog(LOG_ERR, "cannot write PID file '%s'", NGIRCd_PidFile);
  46. + fprintf(fp, "%ld\n", (long)pid);
  47. + fclose(fp);
  48. + umask(old_umask);
  49. + }
  50. +#endif
  51. chdir( "/" );
  52. }
  53. @@ -565,6 +596,9 @@
  54. puts( " -s, --sniffer enable network sniffer and display all IRC traffic" );
  55. #endif
  56. puts( " -t, --configtest read, validate and display configuration; then exit" );
  57. +#ifdef PID_FILE
  58. + puts( " --pidfile <f> write PID into file" );
  59. +#endif
  60. puts( " --version output version information and exit" );
  61. puts( " --help display this help and exit" );
  62. } /* Show_Help */
  63. Index: src/ngircd/ngircd.h
  64. --- src/ngircd/ngircd.h.orig 2002-12-26 17:48:14 +0100
  65. +++ src/ngircd/ngircd.h 2005-03-16 13:15:05 +0100
  66. @@ -45,6 +45,10 @@
  67. GLOBAL CHAR NGIRCd_ConfFile[FNAME_LEN]; /* Konfigurationsdatei */
  68. +#ifdef PID_FILE
  69. +GLOBAL CHAR NGIRCd_PidFile[FNAME_LEN]; /* PID file */
  70. +#endif
  71. +
  72. GLOBAL CHAR NGIRCd_ProtoID[COMMAND_LEN];/* Protokoll- und Server-Identifikation */