Unix Programming - why does execv executes twice?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2005 > why does execv executes twice?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author why does execv executes twice?
puzzlecracker

2005-10-24, 3:47 pm

void somefunc(){
newargv[0] = "script";
newargv[1] = "arg1";
newargv[2] = NULL;

pid_t pid;
if(pid=fork()<0)
{
cerr<<"failed in fork(), exit 1\n";
exit(1);

}
else if(pid==0)
{
if(execv("/home/bin/script",newargv)<0)
{
cerr<<"failed in execv(), exit 1\n";
exit(1);
}
}
}

Måns Rullgård

2005-10-24, 3:47 pm

"puzzlecracker" <ironsel2000@gmail.com> writes:

> if(pid=fork()<0)


Operator precedence: < has higher precedence than =.

--
Måns Rullgård
mru@inprovide.com
Pascal Bourguignon

2005-10-24, 3:47 pm

Måns Rullgård <mru@inprovide.com> writes:

> "puzzlecracker" <ironsel2000@gmail.com> writes:
>
>
> Operator precedence: < has higher precedence than =.


Which means you have to use much more parentheses in C than you think,
which means you could as well write Lisp.

--
__Pascal Bourguignon__ http://www.informatimago.com/
In deep sleep hear sound,
Cat vomit hairball somewhere.
Will find in morning.
Lew Pitcher

2005-10-24, 3:47 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pascal Bourguignon wrote:
> Måns Rullgård <mru@inprovide.com> writes:
>
>
>
>
> Which means you have to use much more parentheses in C than you think,


I should point out that the OP posted C++ code and not C code, and that Måns
reply did not mention C at all.

[snip]

- --
Lew Pitcher
IT Specialist, Enterprise Data Systems,
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed are my own, not my employers')
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFDU6meagVFX4UWr64RAqQPAJ0cKBi+97pz
cjwHe/bqRYkbyWZCvACgrs4G
unnXxOon06+zv+7ZyXPi2QU=
=OOBz
-----END PGP SIGNATURE-----
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com