Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 04-27-2012, 10:32 PM   #1
LQ Newbie
Registered: Apr 2012
Posts: 3

Rep: Reputation: Disabled
System Call Return Values

Hi all,
This is my first post but I have been coming to the site for a long time now.

I have a question regarding creating my own system calls in Ubuntu(version 2.6.35).
I have created my system calls and they work perfectly with the exception that when I check the return value for known bad input in my driver file (how I am calling and testing my system calls) I always receive a negative one. I know my system calls are working because when I use the dmesg command I can see what the system calls are returning right before they return.
When I give valid input my return values match with those in my driver file, what I expect, and the values returned from dmesg. Does anyone have any idea what the reason for this is?


sample output:

Output from dmesg:
[ 2030.296446] rmMbox421:
[ 2030.296447] Mailbox ID: 9
[ 2030.296457] Mailbox 9 could not be removed (DNE).
[ 2030.296461] **Remove Mailbox returned -3

Output from proj2Driver.c:
0) Hello World
1) Create Mailbox
2) Remove Mailbox
3) Count Mailbox
4) List Mailbox
5) Send Message
10) Quit

Enter Option: 2

Enter Mailbox ID: 9
Result from rmMbox421: -1
Old 05-04-2012, 06:38 AM   #2
Senior Member
Registered: Dec 2008
Posts: 4,731
Blog Entries: 29

Rep: Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940Reputation: 940
To me, the question isn't clear enough.
What do you expect as a result when you give a bad input?
What is the system call supposed to do?
Can you post some source code of the system call here for
others to look?
Old 05-04-2012, 06:32 PM   #3
LQ Newbie
Registered: Apr 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hey, Thanks for the response. I have figured out my problem, whenever my system call returned it was always negative one indicated there was an error. My solution was saved the errno value and if the return value was negative one I then checked the errno to see what specific error had occurred. Thanks a bunch,


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
[SOLVED] php, immediate return from system call? MrUmunhum Programming 1 11-29-2011 05:28 PM
system() and return values PatrickNew Programming 1 02-07-2007 05:35 AM
does a system call return value?? docetes Programming 2 03-16-2006 06:40 PM
How to use return values from system functions? kpachopoulos Programming 2 07-30-2004 04:09 AM
How can get values return from a system call quenn Programming 1 09-17-2003 12:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:46 PM.

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