Welcome to the most active Linux Forum on the web.
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 09-14-2009, 09:35 PM   #1
LQ Newbie
Registered: Sep 2009
Location: tulsa, ok
Distribution: n/o
Posts: 5

Rep: Reputation: 0
open local file error when creating file descriptor

I have a error message when I ran my program

that I couldn't open my local file.

I have two files

first one is called client, second one is called server

I am using named pipes to sent a message from client to the other file called server

in client I
used mknod() to create the two named pipes, one for read, one for write

and created new thread in client

using fork() spawned a child process that executed the server file

both named pipes are opened

the client file got the message from the user

and sent it through the named pipes to the server file

when the server receives the message , it needs to verfify it is correct

in the server file, a local file descriptor is created to read and send
this verifing message when it is not correct

but I am getting an OPEN() error

when I tried to open this shared local array buff

and attach it to a file descriptor
where the message is kept

why do I get this error

in server file

int main()
/*both named pipes are open*/



void server(int rfd, int wfd)
int localfile;
char buff[max];
char buff2[max];


if ((localfile = open(buff,0)) < 0) /*error line I have question*/

/* we got a open error */
/* now tell the IPC Client */

sprintf(buff2,"Filename %s Failed on Open Terminating", buff);


if(write(wfd, buff2, n) != n)

/* write error on the IPC descriptor */
Old 09-14-2009, 11:03 PM   #2
Senior Member
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
before you do the sprintf you might want to perror("open failed") to find out what caused the open to fail


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
Too many file open - How can we define Max limit of file descriptor janeshb Linux - Server 11 09-29-2009 11:41 AM
How to run two task and open the same fd(file descriptor) peterhuang Linux - Software 2 05-21-2008 06:03 AM
How many open file descriptor possible in RHEL 4.4 mani77_iitr Red Hat 2 12-12-2007 09:30 AM
LVM error: File Descriptor left open kapil.hazarika Linux - Software 1 06-18-2007 09:03 PM
Low open file descriptor limit Suse 9.2 kryten SUSE / openSUSE 3 12-20-2004 01:20 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:09 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration