Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I am new to C++ on linux, I build a client-server program in c++ on Redhat linux. In which Server is multithreaded. One thread is having infinite loop and ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    3

    how to exit from infinite loop as C++ program close

    Hi,

    I am new to C++ on linux, I build a client-server program in c++ on Redhat linux. In which Server is multithreaded. One thread is having infinite loop and keep Looking for any client Request. That mean server always keep running until or unless it is not killed by Kill [pid] command

    Now my Question is , How to gracefully out from that infinite loop of server program if i close it by kill command.

    Thanks

  2. #2
    Linux Engineer GNU-Fan's Avatar
    Join Date
    Mar 2008
    Posts
    935
    If you want to change the behaviour on a received kill signal, catch it.
    Read about it in chapter "Signal Handling" in
    The GNU C Library

    For threads sharing common variables, I recommend
    https://computing.llnl.gov/tutorials/pthreads/
    (Inter-thread communication)
    Debian GNU/Linux -- You know you want it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...