logging: add function to send message to foreground process
This commit is contained in:
parent
05bd4898a9
commit
7915f52495
2 changed files with 16 additions and 2 deletions
13
logging.c
13
logging.c
|
@ -185,7 +185,7 @@ void LOG_Message(LOG_Severity severity,
|
||||||
/* Send the message also to the foreground process if it is
|
/* Send the message also to the foreground process if it is
|
||||||
still running, or stderr if it is still open */
|
still running, or stderr if it is still open */
|
||||||
if (parent_fd > 0) {
|
if (parent_fd > 0) {
|
||||||
if (write(parent_fd, buf, strlen(buf) + 1) < 0)
|
if (!LOG_NotifyParent(buf))
|
||||||
; /* Not much we can do here */
|
; /* Not much we can do here */
|
||||||
} else if (system_log && parent_fd == 0) {
|
} else if (system_log && parent_fd == 0) {
|
||||||
system_log = 0;
|
system_log = 0;
|
||||||
|
@ -291,6 +291,17 @@ LOG_SetParentFd(int fd)
|
||||||
|
|
||||||
/* ================================================== */
|
/* ================================================== */
|
||||||
|
|
||||||
|
int
|
||||||
|
LOG_NotifyParent(const char *message)
|
||||||
|
{
|
||||||
|
if (parent_fd <= 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return write(parent_fd, message, strlen(message) + 1) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ================================================== */
|
||||||
|
|
||||||
void
|
void
|
||||||
LOG_CloseParentFd()
|
LOG_CloseParentFd()
|
||||||
{
|
{
|
||||||
|
|
|
@ -126,7 +126,10 @@ extern void LOG_OpenSystemLog(void);
|
||||||
/* Stop using stderr and send fatal message to the foreground process */
|
/* Stop using stderr and send fatal message to the foreground process */
|
||||||
extern void LOG_SetParentFd(int fd);
|
extern void LOG_SetParentFd(int fd);
|
||||||
|
|
||||||
/* Close the pipe to the foreground process so it can exit */
|
/* Send a message to the foreground process */
|
||||||
|
extern int LOG_NotifyParent(const char *message);
|
||||||
|
|
||||||
|
/* Close the pipe to the foreground process */
|
||||||
extern void LOG_CloseParentFd(void);
|
extern void LOG_CloseParentFd(void);
|
||||||
|
|
||||||
/* File logging functions */
|
/* File logging functions */
|
||||||
|
|
Loading…
Reference in a new issue