LinuxQuestions.org
Review your favorite Linux distribution.
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 04-23-2009, 03:46 AM   #1
samarthya
LQ Newbie
 
Registered: Apr 2009
Posts: 1

Rep: Reputation: 0
Question fopen called in daemon fails on system reboot.



Hi!
I am facing a unusually simple problem with fopen(). The issue is when my daemon starts up with the machine and is forwarded a request from a client it fails to create a temporary file required to process the request. I located the issue with open with help of SYSLOG, now if i restart this daemon it starts working fine. Has anyone else faced it before?

I have set the permission using UMASK and also ensure the group id and session ID for the daemon.

The daemon tries to write a file under /root, which fails after machine reboot but succeeds when the daemon is explicitly restarted.

- Samarthya.
 
Old 04-23-2009, 07:24 PM   #2
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 808

Rep: Reputation: 178Reputation: 178
Two questions.
  1. Do you specify the file as, for example,
    Code:
    /root/fred.txt
    or do you specify it as
    Code:
    fred.txt
    expecting the current directory to be
    Code:
    /root
    ?

  2. What is the value of errno after the fopen() failure?
 
Old 04-23-2009, 07:46 PM   #3
voyvf
LQ Newbie
 
Registered: Dec 2008
Distribution: Debian, Gentoo, FreeBSD, OpenBSD, Slackware, CentOS
Posts: 27

Rep: Reputation: 16
Posting the daemon section, as well as the fopen section of the code could be helpful, assuming you're not using the int daemon(int nochdir, int noclose); function from unistd.h.
 
Old 04-23-2009, 11:31 PM   #4
saurabh777
LQ Newbie
 
Registered: Oct 2003
Location: india...delhi
Distribution: 7.2
Posts: 3

Rep: Reputation: 0
Unhappy Absolute path.

I use absolute path
Code:
/root/a.txt
Even if i specify
Code:
./a.txt
is there an issue? because if i use
Code:
getcwd()
I get the /root as the current directory.

Thanks,
Samarthya
 
Old 04-24-2009, 12:42 AM   #5
wje_lq
Member
 
Registered: Sep 2007
Location: Mariposa
Distribution: Debian lenny, Slackware 12
Posts: 808

Rep: Reputation: 178Reputation: 178
Please write a simple daemon which does this:
  1. Open the file, using the same fopen() statement that you use in the real daemon.
  2. If it succeeds, syslog that it succeeded.
  3. If it fails, syslog that it failed and syslog the errno.
Then try this daemon at system reboot and then restart it explicitly.

Do they both fail? Both succeed? One succeed, and one fail?
 
  


Reply

Tags
daemon, fopen


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
nfs daemon fails freeindy Linux - Server 1 06-11-2008 04:47 AM
Ultrium 2 - multi-tape error (DUMP: fopen on /dev/tty fails: No such device or addres tbwalter55 Linux - Hardware 0 01-11-2007 09:28 AM
Mandriva 10.1 fails to reboot and shows "No reboot fixup found for your hardware" ROY913 Mandriva 1 12-12-2005 02:10 AM
fopen fails and returns err jackkerouac Programming 3 02-08-2005 09:22 PM
a CGI written in C, problem with an fopen() system call Sm0k3 Programming 2 10-03-2003 02:18 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration