Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getprogname(3) [netbsd man page]

GETPROGNAME(3)						   BSD Library Functions Manual 					    GETPROGNAME(3)

NAME
getprogname, setprogname -- get/set the name of the current program LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> const char * getprogname(void); void setprogname(const char *name); DESCRIPTION
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() explicitly has no effect. However, portable programs that wish to use getprogname() should call setprogname() from main(). On operating systems where getprogname() and setprogname() are implemented via a portability library, this call is needed to make the name available. SEE ALSO
err(3), setproctitle(3) HISTORY
The getprogname and setprogname function calls appeared in NetBSD 1.6. RESTRICTIONS
The string returned by getprogname() is supplied by the invoking process and should not be trusted by setuid or setgid programs. BSD
May 21, 2011 BSD

Check Out this Related Man Page

GETPROGNAME(3)						   BSD Library Functions Manual 					    GETPROGNAME(3)

NAME
getprogname, setprogname -- get or set the program name LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdlib.h> const char * getprogname(void); void setprogname(const char *progname); DESCRIPTION
The getprogname() and setprogname() functions manipulate the name of the current program. They are used by error-reporting routines to pro- duce consistent output. The getprogname() function returns the name of the program. If the name has not been set yet, it will return NULL. The setprogname() function sets the name of the program to be the last component of the progname argument. Since a pointer to the given string is kept as the program name, it should not be modified for the rest of the program's lifetime. In FreeBSD, the name of the program is set by the start-up code that is run before main(); thus, running setprogname() is not necessary. Programs that desire maximum portability should still call it; on another operating system, these functions may be implemented in a portabil- ity library. Calling setprogname() allows the aforementioned library to learn the program name without modifications to the start-up code. SEE ALSO
err(3), setproctitle(3) HISTORY
These functions first appeared in NetBSD 1.6, and made their way into FreeBSD 4.4. BSD
May 1, 2001 BSD
Man Page

8 More Discussions You Might Find Interesting

1. Programming

call functions from diferents programs

hi i have ten program in C, and there are functions what are in all the programs. so, i want to make a directory to store all the functions what are in all the programs, and call them from the C programs. (sending variables and values) is that possible?? how ca i do that?? any idea,... (1 Reply)
Discussion started by: DebianJ
1 Replies

2. Programming

C program

Hi, There is a C program with "check_log(log_loc,log_name,path)" in it. It seems that this C program is calling a check_log function but I didn't see any function called check_log in it. By the way, the C program itself is called 'check_log' I am just trying to learn a litter bit about C.... (6 Replies)
Discussion started by: whatisthis
6 Replies

3. UNIX for Advanced & Expert Users

return code of a process

two programs A and B writting in c++ I am using A to B and I want to know the return code of B. in B ------------------------ int main() { return 11; } ------------------------ in A ------------------------ int main() { system(A); } ------------------------ Is it the right way... (1 Reply)
Discussion started by: filedeliver
1 Replies

4. Programming

return code of a process

two programs A and B writting in c++ I am using A to B and I want to know the return code of B. in B ------------------------ int main() { return 11; } ------------------------ in A ------------------------ int main() { system(A); } ------------------------ Is it the right way... (1 Reply)
Discussion started by: filedeliver
1 Replies

5. UNIX for Dummies Questions & Answers

how to call two programs simultaneously

Hi, i want to call two programs simultaneously from a currently running program so as to distribute the job and fasten the speed. As of now I call the programs one after the other within the main program. e.g. `perl A.pl`; `perl B.pl`; how can I run the two paralelly? urgent ... please... (1 Reply)
Discussion started by: vipinccmb
1 Replies

6. Shell Programming and Scripting

extract a string from main string

i need a shell program,to extract a string from a main string. main string is "madhu" sub string is "mad"..means any word from the main string please di this (1 Reply)
Discussion started by: madhu.it
1 Replies

7. Shell Programming and Scripting

main program is not calling small other programs

I am trying to understand a program in a book and this program suppose to call other programs which are in the same folder, the other programs are called 'lu' and 'add' but for some reason when it gets to the last line of each case to call these programs there is an error message saying ./rolo:... (2 Replies)
Discussion started by: bartsimpsong
2 Replies

8. AIX

Calling functions from main program from dlopened library function

Hello All, I am trying to call a function from the calling main program from a dlopened library function, below is the entire code, when I execute it it crashes with sigill. Can you guys help me out I guess I am missing out on the linker flag or something here. besides I am new to AIX and... (1 Reply)
Discussion started by: syedtoah
1 Replies