-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
57 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,37 @@ | ||
/* | ||
* Copyright 2018 elementary, Inc. (https://elementary.io) | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public | ||
* License along with this program; if not, write to the | ||
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA. | ||
* | ||
* SPDX-License-Identifier: GPL-2.0-or-later | ||
* SPDX-FileCopyrightText: 2018, 2025 elementary, Inc. (https://elementary.io) | ||
* Authors: Corentin Noël <corentin@elementary.io> | ||
*/ | ||
|
||
public class GreeterSessionManager.SubprocessSupervisor : GLib.Object { | ||
public signal void spawned (GLib.Subprocess subprocess); | ||
public string[] exec { get; construct; } | ||
|
||
private GLib.Subprocess? subprocess = null; | ||
|
||
private GLib.Subprocess subprocess; | ||
private string[] exec; | ||
public SubprocessSupervisor (string[] exec) throws GLib.Error { | ||
this.exec = exec; | ||
Object (exec: exec); | ||
} | ||
|
||
construct { | ||
ensure_run.begin (); | ||
} | ||
|
||
~SubprocessSupervisor () { | ||
exec = {}; | ||
subprocess.force_exit (); | ||
if (subprocess != null) { | ||
subprocess.force_exit (); | ||
} | ||
} | ||
|
||
private async void ensure_run () { | ||
try { | ||
subprocess = new GLib.Subprocess.newv (exec, GLib.SubprocessFlags.STDIN_INHERIT | GLib.SubprocessFlags.STDERR_MERGE); | ||
|
||
if (!yield subprocess.wait_check_async ()) { | ||
ensure_run.begin (); | ||
} | ||
} catch (Error e) { | ||
critical (e.message); | ||
critical ("Couldn't create subprocess: %s", e.message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters