File: 0004-Log-ppid-on-error.patch

package info (click to toggle)
libutempter 1.2.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 320 kB
  • sloc: ansic: 1,258; makefile: 194; sh: 134
file content (43 lines) | stat: -rw-r--r-- 1,286 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
From: =?utf-8?q?Christian_G=C3=B6ttsche?= <cgzones@googlemail.com>
Date: Mon, 9 Jan 2023 15:52:49 +0100
Applied-Upstream: https://github.com/altlinux/libutempter/commit/2a735b3e94ca6448f46fbb340673d0136e351b81
Subject: Log ppid on error

When sending an error message to syslog include the parent PID to ease
debugging which program actually called utempter and did so in an
erroneous way.
---
 diag.h | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/diag.h b/diag.h
index 3b7e8c8..6081794 100644
--- a/diag.h
+++ b/diag.h
@@ -22,6 +22,7 @@
 # define UTEMPTER_DIAG_H
 
 # include <syslog.h>
+# include <unistd.h>
 
 # ifdef UTEMPTER_LOG
 #  define log_debug(fmt_, ...) syslog(LOG_DEBUG, fmt_, ##__VA_ARGS__)
@@ -45,12 +46,12 @@
 	} while (0)					\
 /* End of debug_msg definition.  */
 
-# define fatal_error(fmt_, ...)				\
-	do {						\
-		log_error(fmt_, ##__VA_ARGS__);		\
-		print_dbg(fmt_, ##__VA_ARGS__);		\
-		exit(EXIT_FAILURE);			\
-	} while (0)					\
+# define fatal_error(fmt_, ...)							\
+	do {									\
+		log_error("[ppid=%ld] " fmt_, (long)getppid(), ##__VA_ARGS__);	\
+		print_dbg(fmt_, ##__VA_ARGS__);					\
+		exit(EXIT_FAILURE);						\
+	} while (0)								\
 /* End of fatal_error definition.  */
 
 #endif /* UTEMPTER_DIAG_H */