sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit f1268053a62a83c0169b61451d01649a3f3185e3
parent 6388e1e288009fc12af3fe418a6faf8cfe9926f7
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sat, 11 Jun 2016 17:47:26 -0400

Merge pull request #708 from zandrmartin/assign-command

couple small fixes
Diffstat:
Mcommon/util.c | 20++++++++++++--------
Msway/config.c | 2++
2 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/common/util.c b/common/util.c @@ -70,7 +70,7 @@ int get_modifier_names(const char **names, uint32_t modifier_masks) { } pid_t get_parent_pid(pid_t child) { - pid_t parent; + pid_t parent = -1; char file_name[100]; char *buffer = NULL; char *token = NULL; @@ -79,15 +79,19 @@ pid_t get_parent_pid(pid_t child) { sprintf(file_name, "/proc/%d/stat", child); - if ((stat = fopen(file_name, "r")) && (buffer = read_line(stat))) { - fclose(stat); + if ((stat = fopen(file_name, "r"))) { + if ((buffer = read_line(stat))) { + token = strtok(buffer, sep); // pid + token = strtok(NULL, sep); // executable name + token = strtok(NULL, sep); // state + token = strtok(NULL, sep); // parent pid + parent = strtol(token, NULL, 10); + } - token = strtok(buffer, sep); // pid - token = strtok(NULL, sep); // executable name - token = strtok(NULL, sep); // state - token = strtok(NULL, sep); // parent pid + fclose(stat); + } - parent = strtol(token, NULL, 10); + if (parent) { return (parent == child) ? -1 : parent; } diff --git a/sway/config.c b/sway/config.c @@ -101,6 +101,7 @@ static void pid_workspace_cleanup() { pw = config->pid_workspaces->items[i]; if (difftime(ts.tv_sec, *pw->time_added) >= PID_WORKSPACE_TIMEOUT) { + free_pid_workspace(config->pid_workspaces->items[i]); list_del(config->pid_workspaces, i); } } @@ -126,6 +127,7 @@ void pid_workspace_add(struct pid_workspace *pw) { list_pw = config->pid_workspaces->items[i]; if (pw->pid == list_pw->pid) { + free_pid_workspace(config->pid_workspaces->items[i]); list_del(config->pid_workspaces, i); } }