exec function
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > exec function




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    exec function  
Ravi


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-08-07 06:21 PM

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?






[ Post a follow-up to this message ]



    Re: exec function  
Måns Rullgård


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-08-07 06: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





[ Post a follow-up to this message ]



    Re: exec function  
David T. Ashley


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-09-07 06: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)







[ Post a follow-up to this message ]



    Re: exec function  
Giorgos Keramidas


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-09-07 12:18 PM

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).






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 09:06 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register