summaryrefslogtreecommitdiffstats
path: root/proxy/src
diff options
context:
space:
mode:
Diffstat (limited to 'proxy/src')
-rw-r--r--proxy/src/gp_common.h1
-rw-r--r--proxy/src/gp_init.c33
-rw-r--r--proxy/src/gp_proxy.h1
-rw-r--r--proxy/src/gssproxy.c2
4 files changed, 37 insertions, 0 deletions
diff --git a/proxy/src/gp_common.h b/proxy/src/gp_common.h
index 0de698c..ad68e55 100644
--- a/proxy/src/gp_common.h
+++ b/proxy/src/gp_common.h
@@ -26,6 +26,7 @@
#ifndef _GP_COMMON_H_
#define _GP_COMMON_H_
+#include "config.h"
#include "gp_debug.h"
#include "gp_log.h"
diff --git a/proxy/src/gp_init.c b/proxy/src/gp_init.c
index 8d0ebd8..c364edc 100644
--- a/proxy/src/gp_init.c
+++ b/proxy/src/gp_init.c
@@ -31,6 +31,8 @@
#include <fcntl.h>
#include <errno.h>
#include <string.h>
+#include <unistd.h>
+#include <stdio.h>
#include "gp_proxy.h"
void init_server(bool daemonize)
@@ -176,3 +178,34 @@ void init_proc_nfsd(struct gp_config *cfg)
return;
}
}
+
+void write_pid(void)
+{
+ pid_t pid;
+ FILE *f;
+ int ret;
+
+ pid = getpid();
+
+ f = fopen(GP_PID_FILE, "w");
+ if (!f) {
+ ret = errno;
+ GPDEBUG("Failed to open %s: %d (%s)\n",
+ GP_PID_FILE, ret, strerror(ret));
+ return;
+ }
+
+ ret = fprintf(f, "%d\n", pid);
+ if (ret < 0) {
+ GPDEBUG("Failed to write pid to %s\n", GP_PID_FILE);
+ fclose(f);
+ return;
+ }
+
+ ret = fclose(f);
+ if (ret != 0) {
+ GPDEBUG("Failed to close %s: %d (%s)\n"
+ GP_PID_FILE, ret, strerror(ret));
+ return;
+ }
+}
diff --git a/proxy/src/gp_proxy.h b/proxy/src/gp_proxy.h
index beddf61..25f8a43 100644
--- a/proxy/src/gp_proxy.h
+++ b/proxy/src/gp_proxy.h
@@ -88,6 +88,7 @@ void init_server(bool daemonize);
void fini_server(void);
verto_ctx *init_event_loop(void);
void init_proc_nfsd(struct gp_config *cfg);
+void write_pid(void);
/* from gp_socket.c */
int init_unix_socket(const char *file_name);
diff --git a/proxy/src/gssproxy.c b/proxy/src/gssproxy.c
index f1f0d13..4dd0094 100644
--- a/proxy/src/gssproxy.c
+++ b/proxy/src/gssproxy.c
@@ -106,6 +106,8 @@ int main(int argc, const char *argv[])
/* special call to tell the Linux kernel gss-proxy is available */
init_proc_nfsd(gpctx->config);
+ write_pid();
+
vctx = init_event_loop();
if (!vctx) {
return 1;