Skip to main content

Thread: How do I print messages from a daemon?


i have program works this;
1. main()
2. fork()
3. daemonize (setsid, fork, umask, chdir)

global mutex { list of tasks }
4. new pthread: runs server on port foo, adds tasks list
5. main-loop: pops tasks off list , evaluates them
whenever try use cout/clog/cerr, however, messages printed terminal started daemon from. example, start daemon on terminal 1, open terminal 2, send task daemon terminal 2, daemon prints output on terminal 1 (instead of 2).

there way can re-direct output calling terminal? must work on cygwin, freebsd, , unix-like operating systems, way.

thanks!

note: didn't post code because it's long, if want take @ it, will.

quote posted manualqr view post
i have program works this;


whenever try use cout/clog/cerr, however, messages printed terminal started daemon from. example, start daemon on terminal 1, open terminal 2, send task daemon terminal 2, daemon prints output on terminal 1 (instead of 2).

there way can re-direct output calling terminal? must work on cygwin, freebsd, , unix-like operating systems, way.

thanks!

note: didn't post code because it's long, if want take @ it, will.
the question - how daemon supposed know terminal send message to? unless have mechanism send information daemon, daemon has no way know this.

need implement in protocol communicates between requesting program , daemon. sure, *could* send terminal device daemon, , have write directly "/dev/..." entry device, that's kinda sloppy...

lloyd b.


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] How do I print messages from a daemon?


Ubuntu

Comments