Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions src/functions.vala
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ namespace SwayNotificationCenter {

Pid child_pid;
int std_output;
Process.spawn_async_with_pipes (
bool result = Process.spawn_async_with_pipes (
"/",
argvp,
spawn_env,
Expand All @@ -372,6 +372,11 @@ namespace SwayNotificationCenter {
null,
out std_output,
null);
if (!result) {
msg = "Error executing command: %s\n".printf (cmd);
warning (msg);
return false;
}

// stdout:
string res = "";
Expand All @@ -381,10 +386,10 @@ namespace SwayNotificationCenter {
return false;
}
try {
if (channel.read_line (out res, null, null) == IOStatus.NORMAL) {
debug ("Exec output:\n%s", res);
} else {
res = "";
string read = "";
if (channel.read_line (out read, null, null) == IOStatus.NORMAL) {
debug ("Exec output:\n%s", read);
res += read;
}
return true;
} catch (IOChannelError e) {
Expand All @@ -400,7 +405,7 @@ namespace SwayNotificationCenter {
int end_status = 0;
ChildWatch.add (child_pid, (pid, status) => {
Process.close_pid (pid);
GLib.FileUtils.close (std_output);
FileUtils.close (std_output);
end_status = status;
execute_command.callback ();
});
Expand Down