Re: [Vala] Combining async methods with external processes
- From: James Moschou <james moschou gmail com>
- To: Abderrahim Kitouni <a kitouni gmail com>
- Cc: vala-list gnome org
- Subject: Re: [Vala] Combining async methods with external processes
- Date: Tue, 23 Nov 2010 11:16:17 +1030
On 22 November 2010 05:44, Abderrahim Kitouni <a kitouni gmail com> wrote:
Hi,
في ح، 21-11-2010 عند 16:03 +1030 ، كتب James Moschou:
Here's an incredibly pared back version of what I have:
class Task : Object {
Pid _pid;
Source _source;
public async void run_async () {
try {
Process.spawn_async_with_pipes (null,
{"whois", "www.google.com"},
null,
SpawnFlags.SEARCH_PATH |
SpawnFlags.DO_NOT_REAP_CHILD,
null,
out _pid,
null,
null,
null);
_source = new GLibFixes.ChildWatchSource (_pid);
_source.attach (null);
_source.set_callback (run_async.callback);
Just replace the three above lines with:
ChildWatch.add (_pid, (pid, status) => run_async.callback());
and it won't segfault (and won't need fixes in GLib bindings either :-)
yield;
}
catch (Error error) {
stderr.printf ("%s\n", error.message);
}
Process.close_pid (_pid);
}
}
HTH,
Abderrahim
Thanks a lot!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]