*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->NetBSD man pages -> getprogname (3)              
Title
Content
Arch
Section
 

GETPROGNAME(3)

Contents


NAME    [Toc]    [Back]

     getprogname, setprogname - get/set the name of the current program

LIBRARY    [Toc]    [Back]

     Standard C Library (libc, -lc)

SYNOPSIS    [Toc]    [Back]

     #include <stdlib.h>

     const char *
     getprogname(void);

     void
     setprogname(const char *name);

DESCRIPTION    [Toc]    [Back]

     These utility functions get and set the current program's name as used by
     various error-reporting functions.

     getprogname() returns the name of the current program.  This function is
     typically useful when generating error messages or other diagnostic output.
  If the program name has not been set, getprogname() will return
     NULL.

     setprogname() sets the name of the current program to be the last pathname
 component of the name argument.  It should be invoked at the start
     of the program, using the argv[0] passed into the program's main() function.
  A pointer into the string pointed to by the name argument is kept
     as the program name.  Therefore, the string pointed to by name should not
     be modified during the rest of the program's operation.

     A program's name can only be set once, and in NetBSD that is actually
     done by program start-up code that is run before main() is called.
     Therefore, in NetBSD, calling setprogname() from main() has no effect.
     However, it does serve to increase the portability of the program: on
     other operating systems, getprogname() and setprogname() may be implemented
 by a portability library, and a call to setprogname() allows that
     library to know the program name without modifications to that system's
     program start-up code.

SEE ALSO    [Toc]    [Back]

      
      
     err(3), setproctitle(3)

HISTORY    [Toc]    [Back]

     The getprogname and setprogname function calls appeared in NetBSD 1.6.

BSD                            February 11, 2001                           BSD
[ Back ]
 Similar pages
Name OS Title
show_cdscp_confidence HP-UX Displays the current confidence level of clerk calls resulting from CDS control program commands
setmemwindow HP-UX changes the window id of a running program or starts a program in a particular memory window
getprogname FreeBSD get or set the program name
setprogname FreeBSD get or set the program name
units HP-UX conversion program
units IRIX conversion program
lint IRIX a C program checker
pppctl OpenBSD PPP control program
mknetid OpenBSD a YP filter program
units FreeBSD conversion program
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service