Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
kill_nagbar: No need for pointer to pid_t
  • Loading branch information
orestisfl committed May 24, 2020
1 parent 9aa28f3 commit 6e087d4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions include/util.h
Expand Up @@ -143,13 +143,13 @@ char *pango_escape_markup(char *input);
void start_nagbar(pid_t *nagbar_pid, char *argv[]);

/**
* Kills the i3-nagbar process, if *nagbar_pid != -1.
* Kills the i3-nagbar process, if nagbar_pid != -1.
*
* If wait_for_it is set (restarting i3), this function will waitpid(),
* otherwise, ev is assumed to handle it (reloading).
*
*/
void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it);
void kill_nagbar(pid_t nagbar_pid, bool wait_for_it);

/**
* Converts a string into a long using strtol().
Expand Down
4 changes: 2 additions & 2 deletions src/commands.c
Expand Up @@ -1615,8 +1615,8 @@ void cmd_exit(I3_CMD) {
*/
void cmd_reload(I3_CMD) {
LOG("reloading\n");
kill_nagbar(&config_error_nagbar_pid, false);
kill_nagbar(&command_error_nagbar_pid, false);
kill_nagbar(config_error_nagbar_pid, false);
kill_nagbar(command_error_nagbar_pid, false);
load_configuration(NULL, C_RELOAD);
x_set_i3_atoms();
/* Send an IPC event just in case the ws names have changed */
Expand Down
14 changes: 7 additions & 7 deletions src/util.c
Expand Up @@ -287,8 +287,8 @@ static char *store_restart_layout(void) {
void i3_restart(bool forget_layout) {
char *restart_filename = forget_layout ? NULL : store_restart_layout();

kill_nagbar(&config_error_nagbar_pid, true);
kill_nagbar(&command_error_nagbar_pid, true);
kill_nagbar(config_error_nagbar_pid, true);
kill_nagbar(command_error_nagbar_pid, true);

restore_geometry();

Expand Down Expand Up @@ -405,17 +405,17 @@ void start_nagbar(pid_t *nagbar_pid, char *argv[]) {
}

/*
* Kills the i3-nagbar process, if *nagbar_pid != -1.
* Kills the i3-nagbar process, if nagbar_pid != -1.
*
* If wait_for_it is set (restarting i3), this function will waitpid(),
* otherwise, ev is assumed to handle it (reloading).
*
*/
void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it) {
if (*nagbar_pid == -1)
void kill_nagbar(pid_t nagbar_pid, bool wait_for_it) {
if (nagbar_pid == -1)
return;

if (kill(*nagbar_pid, SIGTERM) == -1)
if (kill(nagbar_pid, SIGTERM) == -1)
warn("kill(configerror_nagbar) failed");

if (!wait_for_it)
Expand All @@ -425,7 +425,7 @@ void kill_nagbar(pid_t *nagbar_pid, bool wait_for_it) {
* exec(), our old pid is no longer watched. So, ev won’t handle SIGCHLD
* for us and we would end up with a <defunct> process. Therefore we
* waitpid() here. */
waitpid(*nagbar_pid, NULL, 0);
waitpid(nagbar_pid, NULL, 0);
}

/*
Expand Down

0 comments on commit 6e087d4

Please sign in to comment.