unix: receive pid on non-linux platforms
[lttng-tools.git] / src / common / compat / socket.h
index a510473c35fbdeb4e78e245b35732c7f52e1dca9..464678292b95eed68afa5cc2d9e0311bd6843b41 100644 (file)
@@ -117,6 +117,7 @@ typedef struct ucred lttng_sock_cred;
 struct lttng_sock_cred {
        uid_t uid;
        gid_t gid;
+       pid_t pid;
 };
 
 typedef struct lttng_sock_cred lttng_sock_cred;
@@ -155,7 +156,7 @@ typedef struct lttng_sock_cred lttng_sock_cred;
 #include <ucred.h>
 
 static inline
-int getpeereid(int s, uid_t *euid, gid_t *gid)
+int getpeereid(int s, uid_t *euid, gid_t *gid, pid_t *pid)
 {
        int ret = 0;
        ucred_t *ucred = NULL;
@@ -176,6 +177,13 @@ int getpeereid(int s, uid_t *euid, gid_t *gid)
                goto free;
        }
        *gid = ret;
+
+       ret = ucred_getpid(ucred);
+       if (ret == -1) {
+               goto free;
+       }
+       *pid = ret;
+
        ret = 0;
 free:
        ucred_free(ucred);
This page took 0.025079 seconds and 4 git commands to generate.