Go Back   UNIX Socket FAQ > Languages > C++

Reply
 
Thread Tools Display Modes
  #1  
Old 10-18-2009, 09:04 PM
tomcio tomcio is offline
Regular
 
Join Date: Aug 2006
Location: Poland
Posts: 105
Default Writing daemon in C++

Hello!

I'm working on some kind of UNIX daemon in C++. My server isn't a regular daemon (it's not launched by init process but by normal users (mostly) in their X sessions), so it share so similarities with unix daemons.

I have problem with initializing my daemon. Usually in child processes created by fork() we close all standard I/O streams (stdout, stdin, stderr). I how to do it with C library, but I'm not sure what to do with I/O streams from standard C++ library.

I don't know how to close cin, cout, clog and cerr streams...
Reply With Quote
  #2  
Old 10-19-2009, 11:55 AM
RobSeace RobSeace is offline
Administrator
 
Join Date: Jun 2002
Location: Boston, MA
Posts: 3,382
Default

You don't need to care about the higher-level streams, anymore than you need to
care about the stdio FILE pointers in plain C... Just close the low-level file descriptors,
and/or reopen "/dev/null" on top of them, the same as you would in C...
Reply With Quote
  #3  
Old 08-14-2010, 09:35 PM
vgupta vgupta is offline
 
Join Date: Aug 2010
Posts: 3
Default Creating Daemon in C

Here's a simple implementation to create a Daemon
Creating a Daemon in Linux
Reply With Quote
  #4  
Old 08-15-2010, 09:34 AM
tomcio tomcio is offline
Regular
 
Join Date: Aug 2006
Location: Poland
Posts: 105
Default

Interesting link, thank you
Reply With Quote
Reply

Thread Tools
Display Modes

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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:42 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.