summaryrefslogtreecommitdiff
path: root/src/plugins/pid.c
diff options
context:
space:
mode:
authorValaris <Valaris@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-01-29 16:10:48 +0000
committerValaris <Valaris@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-01-29 16:10:48 +0000
commit620e60eebce2c1f35c5c9a82f6ca365b316587f5 (patch)
tree38a39e0415f419d9a49ae456ed0e26654c23d559 /src/plugins/pid.c
parenta2675f07d7da22a7c6ae11f545bf8f671e785a82 (diff)
downloadhercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.gz
hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.bz2
hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.tar.xz
hercules-620e60eebce2c1f35c5c9a82f6ca365b316587f5.zip
AS OF SVN REV. 5901, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. EVERYTHING ELSE GOES INTO TRUNK AND WILL BE MERGED INTO STABLE BY VALARIS AND WIZPUTER. -- VALARIS git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5094 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/plugins/pid.c')
-rw-r--r--src/plugins/pid.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/plugins/pid.c b/src/plugins/pid.c
new file mode 100644
index 000000000..1ceb49b6f
--- /dev/null
+++ b/src/plugins/pid.c
@@ -0,0 +1,54 @@
+
+#include <stdio.h>
+#include <string.h>
+#ifndef _WIN32
+ #include <unistd.h>
+#else
+ #define getpid GetCurrentProcessId
+#endif
+#ifdef MINGW
+ #include <process.h>
+ #include <io.h>
+#endif
+#include "../common/plugin.h"
+
+PLUGIN_INFO = {
+ "ProcessId",
+ PLUGIN_ALL,
+ "1.0",
+ PLUGIN_VERSION,
+ "Logs the process ID"
+};
+
+PLUGIN_EVENTS_TABLE = {
+ { "pid_create", "Plugin_Init" },
+ { "pid_delete", "Plugin_Final" },
+ { NULL, NULL }
+};
+
+char pid_file[256];
+char *server_name;
+
+void pid_create ()
+{
+ FILE *fp;
+ int len;
+
+ IMPORT_SYMBOL(server_name, 1);
+ len = strlen(server_name);
+ strcpy(pid_file, server_name);
+ if(len > 4 && pid_file[len - 4] == '.') {
+ pid_file[len - 4] = 0;
+ }
+ strcat(pid_file, ".pid");
+ fp = fopen(pid_file, "w");
+ if (fp) {
+ fprintf(fp, "%d", getpid());
+ fclose(fp);
+ }
+}
+
+void pid_delete ()
+{
+ unlink(pid_file);
+}