LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-08-2005, 06:45 PM   #1
jackkerouac
LQ Newbie
 
Registered: Jan 2005
Location: Salt Lake City, Utah
Distribution: debian, osx (not really linux i know)
Posts: 4

Rep: Reputation: 0
fopen fails and returns err


i have written a little lexer and if i compile it on my ancient debian laptop (which is where it will be deployed) the calls to fopen fail (i tried to write them using low level functions "open()" and it failed as well) it returns the error string that we are all familar with by now, no such file or directory.
but that file does exist and i do have permissions for it.

if i compile the same program on my osx machine, everything works out fine.

if i compile it with the low level
int file = open(argv[1], O_RDONLY | O_CREAT);
it doesnt set errno, but the file pointer is empty and i cant find a new file by that name

$ ./myprogram ~/input_file.suffix
$ locate input_file.suffix
/home/myhome/input_file.suffix

which already existed and hasnt been replace by an empty file

i am not sure if this is a kernel problem or a gcc problem or something that isnt really a problem but i am too dumb to figure out.

any help would be appreciated
 
Old 02-08-2005, 06:53 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Possibly it's not interpreting the '~' properly; try it with a complete path spec?
 
Old 02-08-2005, 07:30 PM   #3
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
What do you mean "file pointer is empty"? The "file" variable should be -1 if open() failed...

Last edited by itsme86; 02-08-2005 at 07:33 PM.
 
Old 02-08-2005, 09:22 PM   #4
jackkerouac
LQ Newbie
 
Registered: Jan 2005
Location: Salt Lake City, Utah
Distribution: debian, osx (not really linux i know)
Posts: 4

Original Poster
Rep: Reputation: 0
sorry i didnt replace the *FILE with the int in my conditional clause-
but lex wants a *FILE to connect to yyin
i am recompiling the kernel now so i can get pcmcia suppport to my laptop
then i can post the bit of source that is in question

**update
i just recompiled the kernel and it works fine, i think i must be drunk
not only did it let me install my pcmcia card without feezing the kernel
the program worked how 'bout that for unpredictability
you'd think i was working on the hurd or something -haha

Last edited by jackkerouac; 02-08-2005 at 10:32 PM.
 
  


Reply



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
Samba returns access denied error. wbinfo -t fails. aleida Linux - Networking 2 08-18-2005 09:49 AM
Dual system boot err: rootnoverify(hd1,0),but the hd0 err msg existed befor shut down lilipeng24 Linux - General 3 06-25-2005 12:10 PM
fopen() bcf2 Programming 3 12-23-2004 04:20 AM
return value from fopen when appending? linfan Programming 3 01-21-2004 01:21 PM
gnu-pop3d returns 'ERR quitting on signal' - clues? unknownrisk Linux - Networking 0 11-14-2003 06:29 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

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
Open Source Consulting | Domain Registration