Re: execl!

Murali Nagaraj (murali.n@tatainfotech.com)
Wed, 24 Mar 1999 10:11:31 +0800 (SST)


use
fprintf(stderr," Tr- module");

as the others have pointed out, stdout is buffered. stderr ain't.

On 24 Mar 1999, H. Peter Anvin wrote:

> Followup to: <Pine.3.87.9903240924.A28286-0100000@teil.soft.net>
> By author: G Jalaja Devi <jalaja@teil.soft.net>
> In newsgroup: linux.dev.kernel
> >
> > Have a look at this piece of code.
> > The instructions prior to the execl() function is not getting executed.
> > When I give a getchar() after the printf statement then the "Tr -module"
> > is getting printed.
> > From the manpage, what I had understood is that the execl function
> > replaces the current process image with the new process image.
> > But, Does it replaces the prior instructions also? or what is happening??
> >
>
> The problem is that you're doing write to stdio, which doesn't get
> flushed before you exec(). Put an fflush(NULL); before execl() and
> you're fine.
>
> > int pid;
> > pid = fork();
> > if (pid == 0)
> > {
> > printf("Tr -module");
> > getchar();
> > execl("/sbin/insmod", "insmod", "trc", NULL);
> > }
> > else if (pid < 0)
> > perror("Error in fork - load2.c");
> > else
> > {
> > printf("I am in the parent process");
> >
> > }
>
> -hpa
> --
> "The user's computer downloads the ActiveX code and simulates a 'Blue
> Screen' crash, a generally benign event most users are familiar with
> and that would not necessarily arouse suspicions."
> -- Security exploit description on http://www.zks.net/p3/how.aspb
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.rutgers.edu
> Please read the FAQ at http://www.tux.org/lkml/
>

Murali Nagaraj
Linux Support Team
Systems & Networking

Telephone: +91 (80) 528 4681 Ext 220 Ext 268
email: murali.n@tatainfotech.com

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/