Changes: single-instance library writes log messages to syslog instead of stderr

RevBy: Alexey Shilov, Dmitry Rozenshtein
pull/1/head
Juha Lintula 14 years ago
parent a5345a3220
commit ee9fe47996

1
debian/changelog vendored

@ -4,6 +4,7 @@ applauncherd (3.0.1) unstable; urgency=low
* Changes: Updated list of libraries to preload
* Fixes: NB#291089 - Installation of clock application fails when applauncherd daemon stopped
* Changes: Adds new test for applauncherd re-exec. Checking state of running application when it is updated.
* Changes: single-instance library writes log messages to syslog instead of stderr
-- Alexey Shilov <alexey@trdhcp147241> Mon, 14 Nov 2011 13:39:38 +0200

@ -40,7 +40,7 @@ void report_set_output(enum report_output new_output)
output = new_output;
}
static void vreport(enum report_type type, char *msg, va_list arg)
static void vreport(enum report_type type, const char *msg, va_list arg)
{
char str[400];
char *str_type = "";
@ -87,7 +87,7 @@ static void vreport(enum report_type type, char *msg, va_list arg)
syslog(log_type, "%s%s", str_type, str);
}
void report(enum report_type type, char *msg, ...)
void report(enum report_type type, const char *msg, ...)
{
va_list arg;
@ -96,7 +96,7 @@ void report(enum report_type type, char *msg, ...)
va_end(arg);
}
void die(int status, char *msg, ...)
void die(int status, const char *msg, ...)
{
va_list arg;

@ -41,7 +41,7 @@ enum report_type {
};
extern void report_set_output(enum report_output new_output);
extern void report(enum report_type type, char *msg, ...);
extern void report(enum report_type type, const char *msg, ...);
#ifndef DEBUG_LOGGING_DISABLED
#define debug(msg, ...) report(report_debug, msg, ##__VA_ARGS__)
@ -53,7 +53,7 @@ extern void report(enum report_type type, char *msg, ...);
#define warning(msg, ...) report(report_warning, msg, ##__VA_ARGS__)
#define error(msg, ...) report(report_error, msg, ##__VA_ARGS__)
extern void ATTR_NORET die(int status, char *msg, ...);
extern void ATTR_NORET die(int status, const char *msg, ...);
#endif

@ -1,8 +1,10 @@
set(COMMON "${CMAKE_HOME_DIRECTORY}/src/common")
# Set sources
set(SRC invokelib.c invoker.c report.c search.c)
set(SRC invokelib.c invoker.c ${COMMON}/report.c search.c)
# Set include dirs
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/src/common)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${COMMON})
# Set precompiler flags
add_definitions(-DPROG_NAME_INVOKER="invoker")

@ -1,11 +1,13 @@
set(COMMON "${CMAKE_HOME_DIRECTORY}/src/common")
# Set sources
set(SRC main.cpp)
set(SRC main.cpp ${COMMON}/report.c)
# Find X11
pkg_check_modules(X11 x11 REQUIRED)
# Set include dirs
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${X11_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${X11_INCLUDE_DIRS} ${COMMON})
# Hide all symbols except the ones explicitly exported in the code (like main())
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fPIC")
@ -13,8 +15,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden -fPIC")
# Link as position independent executable
set(CMAKE_EXE_LINKER_FLAGS "-pie -rdynamic")
# Set C++ flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
# Set C flags because of report.c
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC")
# Set link libraries
link_libraries(${X11_LDFLAGS})

@ -30,6 +30,9 @@
#include <fstream>
#include <iostream>
#include <sys/stat.h>
extern "C" {
#include "report.h"
}
#define DECL_EXPORT extern "C" __attribute__ ((__visibility__("default")))
@ -55,8 +58,7 @@ static bool mkpath(const std::string & path)
// are modified by umask
if (chmod(part.c_str(), 0777) == -1)
{
std::cerr << "ERROR!!: chmod() failed: " <<
strerror(errno) << std::endl;
report(report_error, "chmod() failed: %s \n", strerror(errno));
return false;
}
}
@ -70,7 +72,7 @@ int handleXError(Display *dpy, XErrorEvent *e)
{
char errorText[1024];
XGetErrorText( dpy, e->error_code, errorText, sizeof(errorText) );
std::cerr << ( "X ERROR!!: %s\n", errorText );
report(report_error, "Xerror: %s\n", errorText );
return 0;
}
@ -115,7 +117,7 @@ static int clientMsg(Display *disp, Window win, const char *msg,
}
else
{
std::cerr << "ERROR!!: Cannot send " << msg << " event." << std::endl;
report(report_error, "Cannot send %s event.\n", msg);
return EXIT_FAILURE;
}
}
@ -268,8 +270,7 @@ extern "C"
std::string path(LOCK_PATH_BASE + binaryName);
if (!mkpath(path))
{
std::cerr << "ERROR!!: Couldn't create dir " <<
path << std::endl;
report(report_error, "Couldn't create dir %s\n", path.c_str());
return false;
}
@ -285,8 +286,8 @@ extern "C"
if((g_lockFd = open(path.c_str(), O_WRONLY | O_CREAT, 0666)) == -1)
{
std::cerr << "ERROR!!: Couldn't create/open lock file '" <<
path << "' : " << strerror(errno) << std::endl;
report(report_error, "Couldn't create/open lock file '%s' : %s\n",
path.c_str(), strerror(errno));
return false;
}
@ -322,14 +323,14 @@ extern "C"
}
else
{
std::cerr << "ERROR!!: Lock reserved but no window id for binary name found." << std::endl;
report(report_error, "Lock reserved but no window id for binary name found.\n");
XCloseDisplay(dpy);
return false;
}
}
else
{
std::cerr << "ERROR!!: Failed to open display!" << std::endl;
report(report_error, "Failed to open display!\n");
return false;
}
}
@ -364,8 +365,7 @@ int main(int argc, char **argv)
{
if (execve(argv[1], argv + 1, environ) == -1)
{
std::cerr << "ERROR!!: Failed to exec binary '" <<
argv[1] << "' : " << strerror(errno) << std::endl;
report(report_error, "Failed to exec binary '%s' : %s\n", argv[1], strerror(errno));
unlock();
return EXIT_FAILURE;

Loading…
Cancel
Save