473,378 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

daemon mode not quite working

Hi,

I have an application featuring a verbose mode and a daemon mode.
It's working just fine in verbose mode but in daemon mode it doesn't quite
seem to be functioning properly,
I get into Daemon mode with a fork command followed by exit() to be
specific, it looks like:
[C++]
pid = fork();
if (pid < 0)
{
exit(EXIT_FAILURE);
}
else if (pid 0)
{
exit(EXIT_SUCCESS);
}

umask(0);

sid = setsid();
[/C++]
Is there a problem with this? Do I miss anything?
Thanks,
Ron
--
weeks of software enineering safe hours of planing ;)
Jun 27 '08 #1
3 1651
un*****@example.com wrote:
I have an application featuring a verbose mode and a daemon mode.
It's working just fine in verbose mode but in daemon mode it doesn't
quite seem to be functioning properly,
I get into Daemon mode with a fork command followed by exit() to be
specific, it looks like:
[C++]
pid = fork();
if (pid < 0)
{
exit(EXIT_FAILURE);
}
else if (pid 0)
{
exit(EXIT_SUCCESS);
}

umask(0);

sid = setsid();
[/C++]
Is there a problem with this? Do I miss anything?
The problem is that you're posting in a wrong newsgroup. C++ does
not define how "fork" or "umask" or "setsid" works. You need to
post your inquiry in the newsgroup that deals with your OS. You
probably missed the fact that this newsgroup only discusses the
language issues, not interprocess communication provided by your
platform. Sorry.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2
<un*****@example.comwrote in message
Hi,

I have an application featuring a verbose mode and a daemon mode.
It's working just fine in verbose mode but in daemon mode it doesn't quite
seem to be functioning properly,
I get into Daemon mode with a fork command followed by exit() to be
specific, it looks like:
[C++]
pid = fork();
if (pid < 0)
{
exit(EXIT_FAILURE);
}
else if (pid 0)
{
exit(EXIT_SUCCESS);
}

umask(0);

sid = setsid();
[/C++]
Is there a problem with this? Do I miss anything?
1. Nothing C++ language specific here, so it's OT.
2. Post to comp.unix.programmer. Also post as to what you mean by not
functioning properly. Have you tried some tool like ktrace/strace to debug
the problem?

--
http://techytalk.googlepages.com
Jun 27 '08 #3

"Victor Bazarov" <v.********@comAcast.netwrote in message >
un*****@example.com wrote:
[snip OT]
The problem is that you're posting in a wrong newsgroup. C++ does
not define how "fork" or "umask" or "setsid" works. You need to
post your inquiry in the newsgroup that deals with your OS. You
You are very correct in marking the question as OT.
probably missed the fact that this newsgroup only discusses the
language issues, not interprocess communication provided by your
platform. Sorry.
I didn't see any part referring to IPC etc. He is just trying to dameonize a
process, and it's pretty standard set of rules in Unix. Well, of course it's
still OT.

--
http://techytalk.googlepages.com
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rob Hunter | last post by:
Hi all. I want to run a Python daemon that manages a "to-do" queue. I want it so that the daemon is always running, where its running consists of looking at the queue to see if it has any jobs,...
3
by: bmgx | last post by:
This is what I am trying to find out, instruction on how to create a simple daemon on unix systems(Linux), can't find any info on usual sources..
1
by: Bob Swerdlow | last post by:
I've created a Python daemon that starts a bunch of BitTorrent downloader process. Everything is working fine when I start the daemon by hand (logged on as root). I can quit the session and see...
1
by: paul | last post by:
Hi, I find myself writing quite a few daemons in Python and have finally gotten round to abstracting out a lot of the common code. You can find my first attempt at a generic daemon module at: ...
7
by: Michael Ransburg | last post by:
Hi! I have implemented a daemon in C++. It runs all the time, between reboots. Is there a way for other C++ classes to get a reference to the instance of this daemon class in order to call its...
2
by: Steph L | last post by:
Hi, A given Milter program compiles ok on OpenBSD/FreeBSD/Linux but not on Solaris : it uses daemon(3) http://www.openbsd.org/cgi-bin/man.cgi?query=daemon&apropos=0&sektion...
4
by: Esben Stien | last post by:
Any examples how to detach and run as a daemon?. I've seen some use System.out.close() and System.err.close(), but I just can't get it to detach and run as a daemon. I'm on GNU/Linux, using...
3
by: paul | last post by:
I am writing a daemon process that reads data from the serial port / dev/ttyS0. I am using pyserial & the method for setting up a daemon described in "Chris' Python Page"...
4
by: Abhinay | last post by:
Hi, I am a C++ programer but new on linux, I wanted to know that what setting are requires to use library or DLL ( .so ) inside daemon. I am able to use library in normal programs by setting ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.