[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Fork with gtk+-2.0



"Alphex K." schrieb:
> 
> On Tue, 06 Jan 2004 09:39:12 +0100
> Günther Rapp <guenther@rapp-informatik.de> wrote:
> 
> > "Alphex K." schrieb:
> > >
> > > >On Mon, 5 Jan 2004 15:04:15 +0300
> > > >"Alphex K." <alphex@crew.org.ru> wrote:
> > >
> > > >> pid_t pid;
> > > >> pid = fork();
> > > >>
> > > >> if ((pid=fork())==0)
> > > >>      execlp("/bin/xvkbd", "-geometry 800x185-0-0", NULL);
> > > >> else
> > > >>      g_print("Fork failed\n");
> > > >> }
> > >
> > > >You've left out a lot of details. You need to register a singal handler for
> > > >SIGCHLD. If you want to communitate with the child process, you have to setup
> > > >pipes etc.
> > >
> > > >It's better to use one of g_spawn_async or g_spawn_async_with_pipes or
> > > >g_spawn_command_line_async. They take care of a lot of the details for you.
> > >
> > > >Roland
> > > So. I'm think that in my code I can use standart unix non named pipes, if
> > > I create it,ofcouse I'm must use GLib functions to get platform independency,
> > > but I'm don't need for it ;-)
> >
> >  I also have the same problems with fork I only need native unix/linux
> > fork like done the last 20 years.
> >  I figured out that the fork system call does not work with threads I
> > dont know why so long I found
> >  no reason what happens.
> I'm think that you have troubles in your source code
there are only  a few lines of code the thread is started in the main
like this 
     
        pthread_create(&yacc_tid, NULL, argument_thread, NULL);
        gtk_signal_connect (GTK_OBJECT (main_window), "destroy",
                      GTK_SIGNAL_FUNC (gtk_main_quit),
                      NULL);
        gdk_threads_enter();
        gtk_main ();
        gdk_threads_leave();
        _exit(0);

the fork should be started in a callback
/*
                strcpy(command,"x_ray_start ");
                strcat(command,nr_patient);
                strcat(command," '");
                strcat(command,name_patient);      THIS WORKS well
                strcat(command," ");
                strcat(command,vorn_patient);
                strcat(command,"'");
                strcat(command,"&");
                system (command);
*/

                {
                char name_p[128];
                strcpy(name_p,name_patient);
                strcat(name_p," ");
                strcat(name_p,vorn_patient);
                strcat(name_p," ");                   
                strcat(name_p,geb_patient);
                switch( multixraypid = fork() ) {      /* !!!! this does
not work with activ THREADS WHY ??? */
                case -1:
                        BOTCH("XRAY : fork failed");
                case 0:                             /* this is the son
exec a new task */
                        setpgrp();
                       
execlp("x_ray_start","x_ray_start",nr_patient,name_p,(char *)0);
                        _exit(0);
                default:                            /* this is the
father */
                        ;;
                }

 





       
> > If I do not start the thread the same code
> > works well.
> I'm think that U must use : a) only fork(); b) only threads,
> because it true unix way I think ;-)
> > Using the system call
> >  I have no problem to start a second task but then I dont have the
> >  process id to send a signal when the
> >  first process exits.
> So use an another variable to fork() , it may work
> > I also do not need pipes and stuff like this I
> > communicate with shared memory.
> so, it rules ;-)
> >  By this way setting up named pipes for sync communications is really
> > easy and do not need calls I dont know
> >  what happens behind
> in this processes U can use a non named pipes , if U want I can write how it
> to do
> > >
> > > --
> > > Alphex Kaanoken
> > > Senior developer of Crew IT research labs
> > > web: http://crew.org.ru
> > > mailto:Alphex@Crew.Org.RU
> > > _______________________________________________
> > > gtk-app-devel-list mailing list
> > > gtk-app-devel-list@gnome.org
> > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
> >
> > --
> > R=I+S  Rapp Informatik Systeme GmbH
> >        Rosenbühlstr. 24
> >        D-89182 Bernstadt
> >        Tel:  +49 (0)7348-7755
> >        Fax:  +49 (0)7348-6086
> > E-MAIL  mailto: guenther@rapp-informatik.de
> > WEB             www.rapp-informatik.de
> >
> > PS:
> > Senden Sie mir bitte keine Anhänge in Microsoft (.DOC, .PPT) Format
> > Bitte lesen Sie
> > http://www.fsf.org/philosophy/no-word-attachmentsi.de.html
> > Please don't send me any attachment in Microsoft (.DOC, .PPT) format
> > please
> > Read http://www.fsf.org/philosophy/no-word-attachments.html
> 
> --
> Alphex Kaanoken
> Senior developer of Crew IT research labs
> web: http://crew.org.ru
> mailto:Alphex@Crew.Org.RU
> _______________________________________________
> gtk-app-devel-list mailing list
> gtk-app-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

-- 
R=I+S  Rapp Informatik Systeme GmbH
       Rosenbühlstr. 24
       D-89182 Bernstadt
       Tel:  +49 (0)7348-7755
       Fax:  +49 (0)7348-6086
E-MAIL  mailto: guenther@rapp-informatik.de
WEB             www.rapp-informatik.de       

PS:
Senden Sie mir bitte keine Anhänge in Microsoft (.DOC, .PPT) Format
Bitte lesen Sie 
http://www.fsf.org/philosophy/no-word-attachmentsi.de.html
Please don't send me any attachment in Microsoft (.DOC, .PPT) format
please
Read http://www.fsf.org/philosophy/no-word-attachments.html
begin:vcard 
n:Rapp;Günther
tel;fax:+49 (0)7348-6086
tel;work:+49 (0)7348-7755
x-mozilla-html:FALSE
url:www.rapp-informatik.de
org:R=I+S;Rapp Informatik Systeme GmbH
adr:;;Rosenbühlstr. 24;D-89182  Bernstadt;Germany;;
version:2.1
email;internet:guenther@rapp-informatik.de
x-mozilla-cpt:;1312
fn:Günther Rapp
end:vcard


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]