Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

daemon process

0 views
Skip to first unread message

Evan Li

unread,
Mar 31, 2002, 8:25:35 PM3/31/02
to
Greeting,

I developed a socket client application. It reads data from a local
database, and send those data to remote socket server. The application may
connect to multiple server at same time.

The application works pretty fine, it occupy CUP resource about 1% (watched
by top command).

Now I want it to work as a daemon process. So that I add daemon_init()
function, which copied from Richard Stevens's UNIX Network Programming.

Then the application becomes to a daemon, but I works abnormally. It can not
connect to server frequently, and it occupies about 45% CPU resource.

So, I want to know if there is anything else need to be paid attention to
beside daemon_init() to write a multi-threaded, socket client, daemon
process.

Any help will be greatly appreciated.

Thanks in advance.
Evan


phil-new...@ipal.net

unread,
Apr 1, 2002, 12:45:16 PM4/1/02
to
On Mon, 1 Apr 2002 09:25:35 +0800 Evan Li <ev...@gdc.lucent.com> wrote:

| Now I want it to work as a daemon process. So that I add daemon_init()
| function, which copied from Richard Stevens's UNIX Network Programming.
|
| Then the application becomes to a daemon, but I works abnormally. It can not
| connect to server frequently, and it occupies about 45% CPU resource.
|
| So, I want to know if there is anything else need to be paid attention to
| beside daemon_init() to write a multi-threaded, socket client, daemon
| process.

It should work that way if other things are done right. But if you have
not, it might not work. The problem is, we have no idea what other things
could be done right or wrong. Usually a lot of CPU time indicates that
something is spinning in loops around perhaps system calls like accept()
or read() or select().

--
-----------------------------------------------------------------
| Phil Howard - KA9WGN | Dallas | http://linuxhomepage.com/ |
| phil-...@ipal.net | Texas, USA | http://phil.ipal.org/ |
-----------------------------------------------------------------

Evan Li

unread,
Apr 1, 2002, 8:28:12 PM4/1/02
to
Phil,

Thanks for your kindly idea. I figured out the problem finally. The root
cause is that I close all opened fd in daemon_init() including a pipe on
which I called select(). That cause select() returned immediately, and the
thread who called select() occupied too much CPU resource.

Evan

<phil-new...@ipal.net> wrote in message
news:a8a6b...@enews1.newsguy.com...

0 new messages