Sponsored Content
Full Discussion: does perror() set errno?
Top Forums Programming does perror() set errno? Post 302343892 by ebd on Friday 14th of August 2009 02:49:23 AM
Old 08-14-2009
Question does perror() set errno?

here the program gives a odd result:
Code:
#include <stdio.h>
int main(){
    perror("first");
    perror("next");
    return 0;
}

result:

first: Success
next: Illegal seek

why? any resonable explanation? i found no information about this in man pages.
thanks in advance
 

10 More Discussions You Might Find Interesting

1. Programming

Getting errno in a Multithreaded program

In Tru64 Unix, the 'errno' variable is not thread safe. Could anybody help me about how to make it thread safe or how to check 'errno' in a Multithreaded program ???? The Programming process is like this. There are some definite number of threads having their own task. There is one... (2 Replies)
Discussion started by: S.Vishwanath
2 Replies

2. Programming

errno pb

Hello, I need to make a lib with pthread, when I run my make file all is good. But when I run my test program, I test errno in the begining and is already set to 251. Is it normal ??? What can I modify in my Makefile to have errno set to 0 ??? Thanks $make gcc -D_REENTRANT -shared -fpic... (3 Replies)
Discussion started by: dts
3 Replies

3. Programming

Hi errno in sys/stat.h

How should I use errno in a c program and what info does it have . I am working with directories and files. So can any one tell me How to access errno?I am using the stat() function on \etc directory and I am alble to access only the half of the directories.I am not able to access other half and... (6 Replies)
Discussion started by: vijlak
6 Replies

4. Programming

errno

Hey, Can I assume that for certain function calls, errno can never be set to a certain value. More specifically, can I assume that for if the stat function call fails, the errno can never be or "No space left on device." I am assuming that a read function cannot fail because of no space... (5 Replies)
Discussion started by: the_learner
5 Replies

5. Programming

A question about printing error message with perror

Dear all, I use perror in order to print an error message to the standar error. For example if a C program is called without its two necessary command line parameters then : if (argc != 3) { perror("use: ./myProgram <source file> <target file>\n"); return 1; } Now the... (2 Replies)
Discussion started by: dariyoosh
2 Replies

6. UNIX for Dummies Questions & Answers

perror with signals

I have following problem with this code.. First time trough the main loop..... perror gives ....blocked signal:success(all other times gives illlegal seek) Should every time trought the main loop be success?? And the perror otside of main loop...didn't change mask:success That line of code... (2 Replies)
Discussion started by: joker40
2 Replies

7. Programming

help with C programming, perror

i am trying to use the perror function: something like perror("WRONG!!!"); but when i see the message in the terminal, it comes out like WRONG!!! : Success How can i change it to WRONG!!! : WRONG!!! well i just want to have my own custom message for the part after the colon... (1 Reply)
Discussion started by: omega666
1 Replies

8. Programming

need help about get errno [ENXIO] for mmap

from mmap manpage I get it's errors discription: The addresses specified by the range [off, off + len) are invalid for filedes. How could I trigger a ENXIO ? anyone can input the code? Lei (3 Replies)
Discussion started by: yanglei_fage
3 Replies

9. Linux

[Errno 256] No more mirrors to try.

Dear all, CentOS 6 After executing "yum update -y" command I am facing this error. Please help me out. thanks in advance. Full error & error code is given as follow: ... (7 Replies)
Discussion started by: saqlain.bashir
7 Replies

10. AIX

Errno.h symbols

Hi, I need to look at a recent copy of /usr/include/errno.h from AIX 7.2 to check some symbols. In particular, I'm curious if it defines EOWNERDEAD and ENOTRECOVERABLE. Can someone who has access to 7.2 please check for me? Thanks! (1 Reply)
Discussion started by: topcat
1 Replies
perror(3)						     Library Functions Manual							 perror(3)

NAME
perror - Writes a message explaining the current setting of errno LIBRARY
Standard C Library (libc.a, libc.so) SYNOPSIS
#include <stdio.h> void perror( const char *string); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: perror(): ISO C, POSIX.1, XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Points to a string containing the name of the program that caused the error. DESCRIPTION
The perror() function writes a message on the standard error stream that describes the current setting of the external variable errno. The error message includes the string pointed to by the string parameter, followed by a : (colon), a blank, the system message string, and a newline character. The string parameter string should point to the name of the program that caused the error. To get the system error message string for use by a program, as opposed to displaying it on standard error, use the strerror() function. For more information, see strerror(3). RELATED INFORMATION
Routines: printf(3), strerror(3) Standards: standards(5) delim off perror(3)
All times are GMT -4. The time now is 10:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy