[Vala] Looking for program's output
- From: Arkadi Viner <arkashkin gmail com>
- To: vala-list gnome org
- Subject: [Vala] Looking for program's output
- Date: Thu, 30 Jul 2009 17:59:23 +0300
Hi to all.
I am trying to look for some program's output while it is running.
This is my program:
using Gtk;
public class Main
{
/*
public void SpawnCommand (string[] cmd) {
debug ("Running %s", cmd[0]);
try {
Process.spawn_async_with_pipes (null, cmd, null,
SpawnFlags.SEARCH_PATH | SpawnFlags.DO_NOT_REAP_CHILD, null, out child_pid,
null, null, null);
//ChildWatch.add (child_pid, this.child_ended);
} catch (SpawnError e) {
error ("Unable to spawn!");
}
child_pid_t = (Posix.pid_t) child_pid;
}
*/
public static int main (string[] args)
{
Gtk.init (ref args);
try {
var builder = new Builder ();
builder.add_from_file ("Repositor.ui");
builder.connect_signals (null);
var window = builder.get_object ("win_main") as Window;
window.show_all ();
window.destroy += Gtk.main_quit;
Gtk.main ();
} catch (Error e) {
stderr.printf ("Could not load UI: %s\n", e.message);
return 1;
}
return 0;
}
public static void execProgram()
{
string command_line="/home/arkadi";
string[] argv = new string[1];
argv[0] = "/home/arkadi/tt";
//argv[1] = null;
Pid child_pid;
int input_fd;
int output_fd;
int error_fd;
try {
Process.spawn_async_with_pipes(
command_line,
argv, //argv
null, // environment
SpawnFlags.SEARCH_PATH,
null, // child_setup
out child_pid,
out input_fd,
out output_fd,
out error_fd);
}
catch (Error e) {
stderr.printf ("Could not load UI: %s\n", e.message);
}
var iochan = new IOChannel.unix_new(output_fd);
iochan.add_watch(IOCondition.IN, read_from_channel);
}
public bool read_from_channel(IOChannel source, IOCondition cond) {
string str;
size_t c;
source.read_to_end(out str, out c);
stdout.printf("%s", str);
return true;
}
}
It doesn't compile and I don't know why... please help...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]