Working around seg-faults while using syslog

From Notes_Wiki
Revision as of 13:28, 7 April 2022 by Saurabh (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Home > C programming language > Using syslog library with C > Working around seg-faults while using syslog

When we use

 
	openlog("run_commands_on_remote_server:", LOG_PID | LOG_NOWAIT | LOG_NDELAY, LOG_USER);

to configure syslog, then many times we may see lines like

	May  2 10:39:27 basehost2 kernel: watchdog[7327]: segfault at 00000000000000c0 rip 0000003f72853784 rsp 00007fff9519dcb0 error 4

in '/var/log/messages'. These are not easy to resolve. Hence a simple work around is to add

	`sleep 3`

at end of command being run to create a three second delay in running command. This seems to solve the segfault problem. Note that most probably the segfault is due to bug in kernel or logging system, etc. Hence it cannot be solved by modifing code. The same code runs fine sometimes and at other times it gives this error. Adding sleep stops error everytime and hence is very useful.


Home > C programming language > Using syslog library with C > Working around seg-faults while using syslog