LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-04-2008, 04:49 AM   #1
Sathya
Member
 
Registered: Sep 2007
Posts: 33

Rep: Reputation: 15
A general question on daemonizing a process


Hi,

I happened to come across a piece of C code that establishes
connection to oracle database and then daemonize. Since daemonizing
requires forking , then the parent to exit and child to become the session group leader,
i would like to know what would happen to the database connection that
was established. Can the daemon process still access(insert/update into some table) the database schema without any inconsistent behaviour?

I have been reading that "It is not recommended or
really supported to have a connection open and then do a fork()". But
i get confused with all the answers since they say that we might end
up getting ORA-03113 error. But this code has been running quite
successfully.

Please refer to the link which says its bad to fork() http://groups.google.co.in/group/com...aeb9cda37a4fd1

Can you guide me in this, as to what would be the effect of doing such
coding. Is it better to establish db connection after daemonizing?

Thanks
Sathya
 
Old 01-04-2008, 09:54 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
ORA-3113 relates to TWO_TASK settings, ie. the Oracle instance is on a separate box from the process connecting.

We daemonize, but all our stuff runs on the same physical box, so TWO_TASK is not defined.
You have make sure all connections and open files do not close on exec, also.
 
Old 01-04-2008, 02:15 PM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
if you daemonise you generally exit the parent, so there will be no problem
with mixed up sockets.
 
  


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
SPAM question - General Internet Security question LuggerHouse Linux - Security 1 09-07-2007 08:30 AM

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

All times are GMT -5. The time now is 12:56 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