Linux fopen() mistery. Help required.


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Linux fopen() mistery. Help required.
# 1  
Old 03-03-2009
Linux fopen() mistery. Help required.

Hello!

I'm having problems with fopen() call in Linux.

I have shared library (created by myself) that implements some file operations:
Code:
int lib_func(char* file_name) {
...
  fd = fopen(file_name, "r");
  if(!fd) {... exit with error ...}
...
  do something useful using fd
...
  fclose(fd);
...
}

Also I have two programs (pr1 and pr2) that use that library and they call lib_func(): lib_func("/dir/dir/file");

Here is the mystery:
- if I run pr1 from command line, lib_func() is called successfully and file is accessed as required;
- if I run pr2 as daemon, lib_func() is called but fopen() fails with ERRNO=2 (No such file or directory).
How can I fix it to run with pr2?

What I have checked so far:
1. I start pr1 and pr2 strictly in different times (no simultaneous running).
2. File in question exists (I can view it, copy it, delete it from shell).
3. Path to file is absolute.
4. No compile warnings/errors.
5. pr2 is in userspace.
6. Both processes are running from root user and have rights for the file access (777).
7. SELinux is in permissive mode (no effect on system operation).
8. No other process is blocking the file.

Any ideas?
# 2  
Old 03-04-2009
Solved!
# 3  
Old 03-04-2009
What was wrong?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

help plz - fopen()

Hello, I have a problem here, I want to write a function called"myfopen()" instead of "fopen()" for writing this function I must not use the <stdio.h> library, Can you help me? thanks a lot (2 Replies)
Discussion started by: hamed.samie
2 Replies

2. What is on Your Mind?

Linux systemd - Is it really required?

I was testing Fedora 16 mostly to check the new features. One thing that caught my eye as a systems admin is the systemd which is incorporated in Fedora for quite a while now. From the first look of it, this appears more close to Solaris's SMF. With parallelization capabilities, advanced... (0 Replies)
Discussion started by: admin_xor
0 Replies

3. Red Hat

required resize /boot partition in linux

Hi, In my linux box I have installed /boot partition with 100MB. I have done compile for a newer kernel. The both kernels are required to me. Finally /boot partition has using 100%. I need to resize the /boot. Any body give the solution how to do resize the /boot partition without dusturbing the... (2 Replies)
Discussion started by: parsrigum
2 Replies

4. Linux

Required Icon Tray in Linux

Hello I am using linux machine. I need Icon tray in this. "Icon Tray" contains all the icons which we open in the workspace. As such, these icons appear at the bottom (similar to windows i.e.when we open internetexplorer, Word, XLs, these icons appear in the bottom) I have to open so many... (3 Replies)
Discussion started by: nehashine
3 Replies

5. Programming

overhead of fopen/freopen

I always assumed the fopen/freopen is very costly, so when I needed to work with many files within on process I spent extra time to implement a list of FILE * pointers to avoid extra open/reopen but it did not produced any better results. Here is a task at hand - there is a huge stream of data... (4 Replies)
Discussion started by: migurus
4 Replies

6. Programming

fopen() - don't know what I'm doing wrong

This code works fine when I use a command line argument for fopen()'s parameter, but when I change it to a filename, the program freezes upon compilation. input.txt is definitely there, so I can't figure it out. Thanks. #include <stdlib.h> #include <stdio.h> #include <ctype.h> int... (3 Replies)
Discussion started by: lazypeterson
3 Replies

7. Programming

fopen and open

what is the difference between fopen and open fread and read fwrite and write open and create why this much of functions for the i/o when everything does the same...? What is their major difference? In which case, which is the best to use. :confused:'ed Collins (2 Replies)
Discussion started by: collins
2 Replies

8. Solaris

su mistery

Hi All, Today I was logged in with my username (non root) on one of our Solaris 9 boxes and and typed "su - appserver". The strange thing is that I was not prompted for appserver's password and it allowed me to become "appserver" even if I am not root. Can anyone suggest where to look for... (5 Replies)
Discussion started by: midraga
5 Replies

9. Programming

help required for linux MPI

hi I am starting with MPI programming, can anyone suggest me some books for MPI or some good online tutorials which will cover both theory and programming. thanks (0 Replies)
Discussion started by: bhakti
0 Replies

10. UNIX Desktop Questions & Answers

Linux - Help Required

Hi guys! i have spent a whole day browsing and i couldn''t find a provider distributing free linux. I am a beginner and am looking for one that can run on Windows 98SE. Would deeply appreciate if you guys can help me. I went into "mirrors" site and was given lots of directory to d/l but i... (7 Replies)
Discussion started by: huimin0116
7 Replies
Login or Register to Ask a Question