Sponsored Content
Top Forums Programming Small query regarding function "char * strerror(int errnum)" Post 302762679 by Corona688 on Tuesday 29th of January 2013 01:29:44 AM
Old 01-29-2013
Quote:
Originally Posted by Praveen_218
The primary reason to ask this query is because of the fact that the MAN pages themselves not making me sure if the programmer needs to handle any kind of cleanup post calling strerror()? Just like the call to stat(), lstat(), fstat() which create objects of type struct stat on the heap itself (whose address is returned through the pointer struct stat *sb)
They do no such thing. Pointers do not work that way! You cannot "return an address" through a pointer you pass into a function, any more than you can return a number through a number you pass into a function.

You do not need to clean up after strerror -- or stat, lstat, or fstat, either.
 

8 More Discussions You Might Find Interesting

1. Programming

How to convert the "select" function into a "poll" function

i have a program using the select function but i want to convert it to poll... how can i do this? thanks in advance... :) (1 Reply)
Discussion started by: rbolante
1 Replies

2. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

3. HP-UX

ERROR: more than one instance of overloaded function "vprintf" has "C" linkage

Hi people! I've got this own library: -------------------------------------------- Personal.h -------------------------------------------- #ifdef __cplusplus extern "C" { #endif #include <stdio.h> #include <stdarg.h> #include <string.h> ... (0 Replies)
Discussion started by: donatoll
0 Replies

4. Solaris

significance of "+" char in SunOS "ls -l" output

Hi, I've noticed that the permissions output from "ls -l" under SunOS differs from Linux in that after the "rwxrwxrwx" field, there is an additional "+" character that may or may not be there. What is the significance of this character? Thanks, Suan (6 Replies)
Discussion started by: sayeo
6 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

7. Shell Programming and Scripting

Move a line containg "char" above line containing "xchar"

Okay, so I have a rather large text file and will have to process many more and this will save me hours of work. I'm not very good at scripting, so bear with me please. Working on Linux RHEL I've been able to filter and edit and clean up using sed, but I have a problem with moving lines. ... (9 Replies)
Discussion started by: rex007can
9 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
stat(2) 							System Calls Manual							   stat(2)

NAME
stat, fstat, lstat - Provides information about a file SYNOPSIS
#include <sys/types.h> #include <sys/stat.h> int stat( const char *path, struct stat *buffer ); int lstat( const char *path, struct stat *buffer ); int fstat( int filedes, struct stat *buffer ); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: fstat(): POSIX.1, XSH5.0 lstat(): POSIX.1, XSH5.0 stat(): POSIX.1, XSH5.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the pathname identifying the file. Specifies the file descriptor identifying the open file. Points to the stat structure in which information is returned. The stat structure is described in the <sys/stat.h> header file. DESCRIPTION
The stat() function obtains information about the file named by the path parameter. Read, write, or execute permission for the named file is not required, but all directories listed in the pathname leading to the file must be searchable. The file information is written to the area specified by the buffer parameter, which is a pointer to a stat structure, defined in sys/stat.h. The values of the stat structure's member, mode_t, are defined in <sys/mode.h>. The fstat() function is like the stat() function except that the information obtained is about an open file referenced by the filedes parameter. The lstat() function is like the stat() function except in the case where the named file is a symbolic link. In this case, the lstat() function returns information about the link, while the stat() and fstat() functions return information about the file the link references. In the case of a symbolic link, the stat() functions set the st_size field of the stat structure to the length of the symbolic link, and sets the st_mode field to indicate the file type. The stat(), lstat(), and fstat() functions update any time-related fields associated with the file before writing into the stat structure. [Tru64 UNIX] When run on a file in an AdvFS clone fileset, the value returned for st_blocks is the number of blocks in the original file at the time the clone fileset was created. NOTES
Two structure members in <stat.h> uniquely identify a file in a file system: st_ino, the file serial number, and st_dev, the device id for the directory that contains the file. [Tru64 UNIX] However, in the rare case when a user application has been deleting open files, and a file serial number is reused, a third structure member in <stat.h>, the file generation number, is needed to uniquely identify a file. This member, st_gen, is used in addition to st_ino and st_dev. RETURN VALUES
Upon successful completion, a value of 0 (zero) is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. ERRORS
If the stat() or lstat() function fails, errno may be set to one of the following values: Search permission is denied for a component of the path parameter. Either the buffer parameter or the path parameter points to a location outside of the allocated address space of the process. An I/O error occurred while reading from the file system. Too many links were encountered in translating path. The length of the path parameter exceeds PATH_MAX or a pathname component is longer than NAME_MAX. The file named by the path parameter does not exist or is an empty string. A component of the path parameter is not a directory. [Tru64 UNIX] The structure pointed to by the buffer argu- ment cannot correctly represent the value to be returned. This error occurs in applications compiled either on a system earlier than Tru64 UNIX Version 5.0 or on any system while using the __V40_OBJ_COMPAT compiler macro. These applications use a <statfs> structure for the for st_blocks fields that is not compatible with the same structure in Tru64 UNIX Version 5.0. [Tru64 UNIX] For NFS file access, if the stat() or lstat() function fails, errno may also be set to one of the following values: The file position pointer associated with the filedes parameter was negative. Indicates either that the request was for a write access to a file but the specified filename was actually a directory, or that the function was trying to rename a directory as a file. Indicates either that the system file table is full, or that there are too many files currently open in the system. Indicates a stale NFS file handle. An opened file was deleted by the server or another client; a client cannot open a file because the server has unmounted or unexported the remote directory; or the directory that contains an opened file was either unmounted or unexported by the server. If the fstat() function fails, errno may be set to one of the following values: The filedes parameter is not a valid file descriptor. The buffer parameter points to a location outside of the allocated address space of the process. An I/O error occurred while reading from the file system. [Tru64 UNIX] The structure pointed to by the buffer argument cannot correctly represent the value to be returned. This error occurs in applications compiled either on a system earlier than Tru64 UNIX Version 5.0 or or on any system while using the __V40_OBJ_COMPAT compiler macro. These applications use a <statfs> structure for st_blocks fields that is not compatible with the same structure in Tru64 UNIX Version 5.0 or later. RELATED INFORMATION
Functions: chmod(2), chown(2), link(2), mknod(2), open(2), pipe(2), symlink(2), utime(2) Standards: standards(5) delim off stat(2)
All times are GMT -4. The time now is 09:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy