I'm trying to make a gui for an application, but it not run.
i'm trying to send the output of execlp to pipe and read from his
father. but i don't obtain results.
Any advince?
Thank you.
This is the code:
#include<gtk/gtk.h>
#include<glade/glade.h>
#include<string .h>
#include<sys/types.h>
#include<sys/wait.h>
#include<unistd .h>
#include<stdlib .h>
GladeXML *xml;
static void button_widget(G tkWidget *widget,gpointe r data);
int main(int argc,char *argv[])
{
GtkWidget *button1;
GtkWidget *principal;
gtk_init(&argc, &argv);
xml = glade_xml_new(" gtk.glade",NULL ,NULL);
principal = glade_xml_get_w idget(xml,"prin cipal");
button1 = glade_xml_get_w idget(xml,"boto 1");
g_signal_connec t(G_OBJECT(prin cipal),"delete-event",
G_CALLBACK(gtk_ main_quit),prin cipal);
g_signal_connec t(G_OBJECT(butt on1),"clicked",
G_CALLBACK(butt on_widget),NULL );
gtk_main();
return 0;
}
void button_widget(G tkWidget *widget,gpointe r data)
{
//GtkWidget *textview;
//GtkWidget *entry;
//GtkTextBuffer *buffer;
//const gchar *text;
gint a[2];
gint pid;
gchar cbuffer[BUFSIZ+1];
memset(cbuffer, '\0',strlen(cbu ffer));
if(pipe(a) ==0)
{
if((pid = fork()) ==0)
{
close(1);
dup(a[1]);
close(a[1]);
if(execlp("tran slate","transla te","yes",NUL L) == -1)
perror("No executat");
}
else
{
int i;
wait(&i);
close(a[1]);
close(0);
dup(a[0]);
close(a[0]);
if( (i= read(a[0],cbuffer,strlen (cbuffer))==0))
printf("Error\n ");
printf("***%s hello",cbuffer) ;
}
}
}