Commit 1258dfb1 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Upstream patch to improve startup behaviour

parent 0e816fc2
fix-tests.patch
startup-improvements.patch
Description: Various startup improvements
This handles -- as argument correctly, no longer forks from children and gives
better return codes for synctec handling.
Origin: upstream,
https://git.pwmt.org/pwmt/zathura/commit/3dd360a27dd8a06be07d25ab817a6d7596b4b0d2,
https://git.pwmt.org/pwmt/zathura/commit/f1d027e6566cb40cfaacd8057508a2f8ce29c57e,
https://git.pwmt.org/pwmt/zathura/commit/fec81cf40b0a9d7aad95298d22edff6f2ac7ec77,
https://git.pwmt.org/pwmt/zathura/commit/564ae2bdd637472a097f4743d0319fc43d53d3bc
Bug-Debian: https://bugs.debian.org/811032
Last-Update: 2016-01-22
--- zathura-0.3.4.orig/zathura/dbus-interface.c
+++ zathura-0.3.4/zathura/dbus-interface.c
@@ -469,7 +469,7 @@ iterate_instances_call_synctex_view(cons
const bool ret = call_synctex_view(connection, filename, well_known_name,
input_file, line, column);
g_free(well_known_name);
- return ret ? 1 : 0;
+ return ret ? 1 : -1;
}
GVariant* vnames = g_dbus_connection_call_sync(
--- zathura-0.3.4.orig/zathura/main.c
+++ zathura-0.3.4/zathura/main.c
@@ -196,9 +196,13 @@ main(int argc, char* argv[])
}
const int ret = run_synctex_forward(synctex_fwd, argv[1], synctex_pid);
- if (ret != 0) {
- /* Error or instance found */
- return ret;
+ if (ret > 0) {
+ /* Instance found. */
+ return 0;
+ }
+ else if (ret < 0) {
+ /* Error occurred. */
+ return -1;
}
girara_debug("No instance found. Starting new one.");
@@ -211,10 +215,19 @@ main(int argc, char* argv[])
return -1;
}
- size_t file_idx = argc > 1 ? 1 : 0;
+ /* g_option_context_parse has some funny (documented) behavior:
+ * * for "-- a b c" you get no -- in argv
+ * * for "-- --" you get -- in argv twice
+ * * for "-- -a" you get -- in argv
+ *
+ * So if there is one -- in argv, we need to ignore it. */
+ const bool has_double_dash = argc > 1 && g_strcmp0(argv[1], "--") == 0;
+ const int file_idx_base = has_double_dash ? 2 : 1;
+
+ int file_idx = argc > file_idx_base ? file_idx_base : 0;
/* Fork instances for other files. */
- if (print_version == false && argc > 2) {
- for (int idx = 2; idx < argc; ++idx) {
+ if (print_version == false && argc > file_idx_base + 1) {
+ for (int idx = file_idx_base + 1; idx < argc; ++idx) {
const pid_t pid = fork();
if (pid == 0) { /* child */
file_idx = idx;
@@ -222,6 +235,7 @@ main(int argc, char* argv[])
girara_error("Could not start new process group: %s", strerror(errno));
return -1;
}
+ break;
} else if (pid < 0) { /* error */
girara_error("Could not fork: %s", strerror(errno));
return -1;
@@ -230,7 +244,7 @@ main(int argc, char* argv[])
}
/* Fork into the background if the user really wants to ... */
- if (print_version == false && forkback == true && file_idx < 2) {
+ if (print_version == false && forkback == true && file_idx < file_idx_base + 1) {
const pid_t pid = fork();
if (pid > 0) { /* parent */
return 0;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment