[Prev][Next][Index][Thread]
Re: fork & exec.
Many suggested using the wait function call however since it seems Asaf
is using the X window systems, it would be problematic. wait would
suspend all user interaction. An alternative way in X would be to use
the XtAddInput(3X) (or sth. like that I don't have the man page in front
of me) in the parent process. Before forking use pipe(2) to direct
stderr to a pipe between the parent and child. You could also monitor
the SIGCHLD but that might prove problematic to incorporate into an X
application , since you need to return to the X main loop before you
continue to perform X operations. There's a section about using signals
and Motif applications in O'Reilly's but I've never tested these things.
Yuval
Erez Strauss wrote:
>
> Hello Asaf,
>
> After returning from the fork(2) system call you should call the wait(2)
> system call, it will set the status bit mask to the exit status from the
> tar comman, in your case value 3.
> try the command
>
> man 2 wait
>
> good luck
>
> Erez
>
> On Tue, 5 Nov 1996, Asaf Sabag wrote:
>
> > Amos, guys.
> >
> > Maybe I did not make my self clear,
> >
> > When I do exec for /bin/tar the tar command is found and exec execute the tar.
> >
> > For example:
> > ------------
> >
> > if (pid = fork() == 0) {
> > execid = execl("/bin/tar", "tar", "cvf", "/dev/fdo", 0)
> > perror("exec failed");
> > }
> > printf("exec passed\n");
> >
> > the exec execute the tar and the exec passes OK.
> > No error is printed.
> > the massage : "exec passed" comes.
> >
> > The problem is that if there is no disk in the drive or if there is no tar
> > file in it then the tar failes!
> >
> > This leads to no error from exec! beacuse exec passed.
> > and the massage "exec passed" comes,
> >
> > If I use the system command and tar failes I get an error masaage from tar.
> >
> > For example:
> > ------------
> >
> > if (i = system("/bin/tar xvf /dev/fd0 > /tmp/TarList.txt") == 0)
> > XtManageChild(SysToolOBJ.DialogGoodExpand_ExpandDevice);
> > else
> > XtManageChild(SysToolOBJ.ErrorMsgExpandFailed_ExpandDevice);
> >
> >
> > I want to execute the same command with exec not system.
> > But I don't get the error massage from tar within exec.
> >
> > HOW can I make it work with exec???
> >
> > BTW. I understand that there are no jumpers on the social life meetings???
> >
> > Thanks,
> > Asaf.
> >
> >
> > --------------------------------------------------------
> > Name : Asaf Sabag NetManage - SQA Haifa
> > E-mail : Asaf Sabag <asaf@netmanage.co.il>
> > Date : 11/05/96
> > Time : 09:55:54
> >
> > This message was sent by Z-Mail Pro - from NetManage
> > NetManage - delivers Standards Based IntraNet Solutions
> > --------------------------------------------------------
> >
> >
> >
References: