mirror of
https://github.com/labwc/labwc.git
synced 2026-04-10 08:21:07 -04:00
Merge 59bb6daf02 into d96656ccdc
This commit is contained in:
commit
0f49b01cef
2 changed files with 35 additions and 2 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
|
@ -176,7 +176,7 @@ jobs:
|
||||||
cd "$GITHUB_WORKSPACE"
|
cd "$GITHUB_WORKSPACE"
|
||||||
export CC=gcc
|
export CC=gcc
|
||||||
meson setup build-gcc-static_analyzer -Dxwayland=enabled \
|
meson setup build-gcc-static_analyzer -Dxwayland=enabled \
|
||||||
-Dstatic_analyzer=enabled --werror
|
-Dstatic_analyzer=enabled -Dc_args="-Wno-analyzer-fd-leak" --werror
|
||||||
meson compile -C build-gcc-static_analyzer
|
meson compile -C build-gcc-static_analyzer
|
||||||
' | $TARGET
|
' | $TARGET
|
||||||
|
|
||||||
|
|
|
||||||
35
src/main.c
35
src/main.c
|
|
@ -1,5 +1,6 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0-only
|
// SPDX-License-Identifier: GPL-2.0-only
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
|
#include <fcntl.h>
|
||||||
#include <pango/pangocairo.h>
|
#include <pango/pangocairo.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
@ -22,6 +23,7 @@ static const struct option long_options[] = {
|
||||||
{"debug", no_argument, NULL, 'd'},
|
{"debug", no_argument, NULL, 'd'},
|
||||||
{"exit", no_argument, NULL, 'e'},
|
{"exit", no_argument, NULL, 'e'},
|
||||||
{"help", no_argument, NULL, 'h'},
|
{"help", no_argument, NULL, 'h'},
|
||||||
|
{"logfile", required_argument, NULL, 'l'},
|
||||||
{"merge-config", no_argument, NULL, 'm'},
|
{"merge-config", no_argument, NULL, 'm'},
|
||||||
{"reconfigure", no_argument, NULL, 'r'},
|
{"reconfigure", no_argument, NULL, 'r'},
|
||||||
{"startup", required_argument, NULL, 's'},
|
{"startup", required_argument, NULL, 's'},
|
||||||
|
|
@ -38,6 +40,7 @@ static const char labwc_usage[] =
|
||||||
" -d, --debug Enable full logging, including debug information\n"
|
" -d, --debug Enable full logging, including debug information\n"
|
||||||
" -e, --exit Exit the compositor\n"
|
" -e, --exit Exit the compositor\n"
|
||||||
" -h, --help Show help message and quit\n"
|
" -h, --help Show help message and quit\n"
|
||||||
|
" -l, --logfile <path> Log to file instead of stderr\n"
|
||||||
" -m, --merge-config Merge user config files/theme in all XDG Base Dirs\n"
|
" -m, --merge-config Merge user config files/theme in all XDG Base Dirs\n"
|
||||||
" -r, --reconfigure Reload the compositor configuration\n"
|
" -r, --reconfigure Reload the compositor configuration\n"
|
||||||
" -s, --startup <command> Run command on startup\n"
|
" -s, --startup <command> Run command on startup\n"
|
||||||
|
|
@ -152,6 +155,7 @@ idle_callback(void *data)
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
char *logfile = NULL;
|
||||||
char *startup_cmd = NULL;
|
char *startup_cmd = NULL;
|
||||||
char *primary_client = NULL;
|
char *primary_client = NULL;
|
||||||
enum wlr_log_importance verbosity = WLR_ERROR;
|
enum wlr_log_importance verbosity = WLR_ERROR;
|
||||||
|
|
@ -159,7 +163,7 @@ main(int argc, char *argv[])
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
c = getopt_long(argc, argv, "c:C:dehmrs:S:vV", long_options, &index);
|
c = getopt_long(argc, argv, "c:C:dehl:mrs:S:vV", long_options, &index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -176,6 +180,9 @@ main(int argc, char *argv[])
|
||||||
case 'e':
|
case 'e':
|
||||||
send_signal_to_labwc_pid(SIGTERM);
|
send_signal_to_labwc_pid(SIGTERM);
|
||||||
exit(0);
|
exit(0);
|
||||||
|
case 'l':
|
||||||
|
logfile = optarg;
|
||||||
|
break;
|
||||||
case 'm':
|
case 'm':
|
||||||
rc.merge_config = true;
|
rc.merge_config = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -203,6 +210,31 @@ main(int argc, char *argv[])
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logfile) {
|
||||||
|
/*
|
||||||
|
* O_NONBLOCK is important to prevent blocking
|
||||||
|
* on write() with mandantory file locking enabled.
|
||||||
|
*/
|
||||||
|
int fd = open(logfile, O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, 0666);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror("Failed to open logfile");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* If stderr was closed before a exec labwc we could end up with 'fd' being 2.
|
||||||
|
* This is not an issue with dup2() because it turns into a no-op but we don't
|
||||||
|
* want to close it in that case.
|
||||||
|
*/
|
||||||
|
if (fd != STDERR_FILENO) {
|
||||||
|
if (dup2(fd, STDERR_FILENO) < 0) {
|
||||||
|
perror("Failed to replace stderr with log file descriptor");
|
||||||
|
close(fd);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wlr_log_init(verbosity, NULL);
|
wlr_log_init(verbosity, NULL);
|
||||||
|
|
||||||
die_on_detecting_suid();
|
die_on_detecting_suid();
|
||||||
|
|
@ -276,5 +308,6 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
server_finish(&server);
|
server_finish(&server);
|
||||||
|
|
||||||
|
close(STDERR_FILENO);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue