int execl(const char *path, const char *arg, ...);
lol wat the fuck is this shit the number of arguments is not specified exactly reported to the anis/ecma committee for anus penalty
#include <unistd.h>
int main(int argc, char *argv[])
{
path = "/bin/true";
return execl(path, path);
}
hopeless. all of you.
don't you know that the argv[0] should be the name of the program?
>>13
"Should", yes, technically speaking: Early proposals required that the value of argc passed to main() be
"one or greater". This was driven by the same requirement in drafts of
the ISO C standard. In fact, historical implementations have passed a
value of zero when no arguments are supplied to the caller of the exec
functions. This requirement was removed from the ISO C standard and
subsequently removed from this volume of IEEE Std 1003.1-2001 as well.
The wording, in particular the use of the word should, requires a
Strictly Conforming POSIX Application to pass at least one argument to
the exec function, thus guaranteeing that argc be one or greater when
invoked by such an application. In fact, this is good practice, since
many existing applications reference argv[0] without first checking the
value of argc.
However, there's nothing disallowingargv[0] from being NULL; and in any event, there's really no reason why true ought to be poking at argv-anything.
>>17
So the solution to poor, unrobust design is a poor, unrobust "good practice"?
Name:
Anonymous2009-10-31 5:55
>>17
i just checked the source for true (on Linux, Ubanto): int main(int argc, char *argv[])
{
if(return(0) != 0)
{
err(1, argv[0]);
}
}
obviously, it encountered an error while returning 0 and segfaulted when it tried to report said error.
Name:
Anonymous2009-10-31 6:10
/* @true.c */
int main() {
return 0;
}
Name:
Haxus the True2009-10-31 6:37
/*
True
Copyright (C)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
>>24
That implementation lacks the GNU standard --help and --version options, and also is not internationalized properly.
Sorry, can't accept into mainline until you fix these egregious errors.
Name:
Anonymous2009-10-31 16:01
tolva:~ snorri$ cat truetest.c
#include <unistd.h>
int main(int argc, char *argv[])
{
return execl("/bin/true", NULL);
}
tolva:~ snorri$ ./a.out
tolva:~ snorri$ grep ' 22$' /usr/include/errno.h
tolva:~ snorri$ uname -a
Darwin tolva 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-1456.1.25~1/RELEASE_I386 i386
tolva:~ snorri$