|
Home > Archive > Unix Programming > July 2007 > exec function
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]
|
|
|
| int execl(const char *path, const char *arg, ...); The first
argument, by convention, should point to the filename associated with
the file being executed.
Why? whats the significance of this?
| |
| Måns Rullgård 2007-07-08, 1:21 pm |
| Ravi <ra.ravi.rav@gmail.com> writes:
> int execl(const char *path, const char *arg, ...); The first
> argument, by convention, should point to the filename associated with
> the file being executed.
> Why? whats the significance of this?
None at all. That's what convention means. Some programs change
their behaviour based on the value of argv[0] so adhering to the
convention is recommended unless you have a specific reason to do
otherwise.
--
Måns Rullgård
mans@mansr.com
| |
| David T. Ashley 2007-07-09, 1:17 am |
| "Ravi" <ra.ravi.rav@gmail.com> wrote in message
news:1183909977.157322.265560@c77g2000hse.googlegroups.com...
> int execl(const char *path, const char *arg, ...); The first
> argument, by convention, should point to the filename associated with
> the file being executed.
> Why? whats the significance of this?
It is unclear where you got this prose from (my "man" doesn't say it like
this). Two potential points of relevance:
a)For execl(), I believe a path has to be specified (otherwise, what would
you load?), AND
b)It is very common in *nix systems to symlink/hardlink/duplicate a bunch of
programs that are actually the same executable image but are just given
different names. The program then makes decisions about its behavior based
on what name it is invoked under.
This is most commonly done either for programs with different names but
identical functionality or different names but related functionality. For
example, on my Linux system, I think but am not sure that "poweroff",
"halt", and "reboot" are the same program file. But it tailors its behavior
based on what name it is invoked under.
--
David T. Ashley (dta@e3ft.com)
http://www.e3ft.com (Consulting Home Page)
http://www.dtashley.com (Personal Home Page)
http://gpl.e3ft.com (GPL Publications and Projects)
| |
| Giorgos Keramidas 2007-07-09, 7:18 am |
| On Sun, 8 Jul 2007 22:03:45 -0400, "David T. Ashley" <dta@e3ft.com> wrote:
> b)It is very common in *nix systems to symlink/hardlink/duplicate a
> bunch of programs that are actually the same executable image but are
> just given different names. The program then makes decisions about
> its behavior based on what name it is invoked under.
>
> This is most commonly done either for programs with different names
> but identical functionality or different names but related
> functionality. For example, on my Linux system, I think but am not
> sure that "poweroff", "halt", and "reboot" are the same program file.
> But it tailors its behavior based on what name it is invoked under.
Indeed. This is true for at least `halt' and `reboot' here too:
% # /bin/ls -ldi $(for prog in reboot halt shutdown ; do \
% which $prog ; done)
% 6029412 -r-xr-xr-x 4 root wheel 15879 Jun 26 09:19 /sbin/halt
% 6029412 -r-xr-xr-x 4 root wheel 15879 Jun 26 09:19 /sbin/reboot
% 6029423 -r-sr-x--- 1 root operator 25058 Jun 26 09:19 /sbin/shutdown
% # uname -msr
% FreeBSD 7.0-CURRENT i386
% #
and it has been so for a long time (note the i-node of `halt' and
`reboot' in the listing above).
|
|
|
|
|