Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9151369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:47:05+00:00 2026-06-17T11:47:05+00:00

I created a client-server application and now I would like to deploy it. While

  • 0

I created a client-server application and now I would like to deploy it.

While development process I started the server on a terminal and when I wanted to stop it I just had to type “Ctrl-C”.

Now want to be able to start it in background and stop it when I want by just typing:

/etc/init.d/my_service {stop|stop}

I know how to do an initscript, but the problem is how to actually stop the process ?

I first thought to retrieve the PID with something like:

ps aux | grep "my_service"

Then I found a better idea, still with the PID: Storing it on a file in order to retrieve it when trying to stop the service.

Definitely too dirty and unsafe, I eventually thought about using sockets to enable the “stop” process to tell the actual process to shut down.

I would like to know how this is usually done ? Or rather what is the best way to do it ?

I checked some of the files in the init.d and some of them use PID files but with a particular command “start-stop-daemon”. I am a bit suspicious about this method which seems unsafe to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T11:47:07+00:00Added an answer on June 17, 2026 at 11:47 am

    If you have a utility like start-stop-daemon available, use it.

    start-stop-daemon is flexible and can use 4 different methods to find the process ID of the running service. It uses this information (1) to avoid starting a second copy of the same service when starting, and (2) to determine which process ID to kill when stopping the service.

    • --pidfile: Check whether a process has created the file pid-file.
    • --exec: Check for processes that are instances of this executable
    • --name: Check for processes with the name process-name
    • --user: Check for processes owned by the user specified by username or uid.

    The best one to use in general is probably --pidfile. The others are mainly intended to be used in case the service does not create a PID file. --exec has the disadvantage that you cannot distinguish between two different services implemented by the same program (i.e. two copies of the same service). This disadvantage would typically apply to --name also, and, additionally, --name has a chance of matching an unrelated process that happens to share the same name. --user might be useful if your service runs under a dedicated user ID which is used by nothing else. So use --pidfile if you can.

    For extra safety, the options can be combined. For example, you can use --pidfile and --exec together. This way, you can identify the process using the PID file, but don’t trust it if the PID found in the PID file belongs to a process that is using the wrong executable (it’s a stale/invalid PID file).

    I have used the option names provided by start-stop-daemon to discuss the different possibilities, but you need not use start-stop-daemon: the discussion applies just as well if you use another utility or do the matching manually.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting started with iPhone application development and would like to create an
I would like to have a client-server application written in .NET which would do
Im trying to create a server/client application that will work on two or more
I've recently created a fairly simple IRC client and server in Java but to
I have created my web socket server and client using this simple tutorial here
I have created a server in java which accepts client connections. But I am
On a client operation, a file is created on the server and I want
I have to add e-mail notifications to a client server application. Notifications happen as
I would like to create a small Windows Messenger Client that I can trigger
I would like to send dynamically created images to my users, such as charts,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.