LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-19-2010, 04:35 PM   #1
jerbs
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Rep: Reputation: 0
Error checking on system calls


Hey guys,

I'm new to C language and some help finding places in the following code where a system call is made and error checking is not done. I found one but since I don't know C language at all I'm not exactly sure what else to look for. Link to my file: http://www.mediafire.com/?wqwws95qff5yw87

I found one and added error checking:
if (setoutpipe){
//Changes: Added error checking to the system call close()
//Orginal Code: close(pidefd[1]);
if(close(pipefd[1] != 0){
fprintf(stderr, "Could not close piple.\n");
exit(255);
}

Any tips, advice or examples would be much appreciated thanks.
 
Old 09-20-2010, 11:50 AM   #2
hda7
Member
 
Registered: May 2009
Distribution: Debian wheezy
Posts: 252

Rep: Reputation: 31
LinuxQuestions.org has an attachment system. Please attach your file by clicking the "Manage Attachments" button under "Additional Options" when you post.
NOTE: You may have to rename your file with a ".txt" extension.

As to your question, check the man page for each system call. Each call usually returns a specific value (e.g., -1) when an error occurs, and sets a variable "errno" to a value which indicates the nature of the error. You should include the header errno.h (by writing "#include <errno.h>" on its own line near the top of the file), and use its functions to access errno. For example, if an error occurs, you can use
Code:
perror("call name")
to print out a description of the error.

Finally, a little LQ etiquette: if someone helps you, click the scales icon on their post, and when your question is answered, click "Thread tools -> Mark thread as solved"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how does java calls the system calls which are written in c babu198649 Linux - General 3 12-05-2011 03:40 AM
C - system call & error checking UltimateDesi Programming 5 09-19-2010 09:36 PM
system calls arispipis Programming 2 03-19-2008 06:59 PM
checking system version (for dynamic loading) = ERROR nykey Linux From Scratch 7 06-06-2006 12:44 AM
system crashes, checking filesystems error iclinux Linux - Newbie 1 01-21-2005 02:42 AM


All times are GMT -5. The time now is 10:25 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration