[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Complete example of daemon with multiprocess


On Monday, 20 February 2017 19:29:43 CET Maxy wrote:
> I need to make a multiprocess/multithreaded daemon (i don't mind if multi
> thread/process, i will use the simple way in libssh).
> 
> I followed the example samplesshd-tty.c, but i have some problems.
> I understood the example, but it seems too simple, and mono-process
> (although it uses forkpty). I need some help for

Did you look at examples/ssh_server_fork.c ???

I would suggest to write a prefork server. The parent should have a small 
memory footprint so it is fast to fork. Then do the heavy lifting and wait for 
a connection.

Forking is better because if you have a segfault only the process for client 
connection dies.

About threading:
http://bholley.net/blog/2015/must-be-this-tall-to-write-multi-threaded-code.html


Improved examples are always welcome.


	Andreas



-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx

References:
Complete example of daemon with multiprocessMaxy <maxy0440yxam@xxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org