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

  • SEARCH
  • Home
  • 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 7738499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:16:52+00:00 2026-06-01T08:16:52+00:00

I am creating a TFTP server and keep it running using a infinite loop.

  • 0

I am creating a TFTP server and keep it running using a infinite loop. When i try to send a kill signal

/bin/kill -s SIGINT <pid>

I want Java process to close TFTP server and exit.

class TFTP {
public void startTFTP(String str, String str1){
    try {
        //Start TFTP server
            // Both of below are not working.
            Runtime.getRuntime().addShutdownHook(new Thread(){
                @Override
                public void run(){
                    //Shutdown tftp server
                    System.out.println("Exiting");
                    System.exit(0);
                }
            });

            SignalHandler handler = new SignalHandler () {
                public void handle(Signal signal) {
                    System.exit(0);
                }
            };
            Signal.handle(new Signal("INT"), handler);
            Signal.handle(new Signal("TERM"), handler);

            while(true){
            // Infinite loop to keep process running.
            }
        }
    } catch (Exception e) {

    }
}
public static void main(String args[]){
        TFTP tftp = new TFTP();
        tftp.startTFTP(args[0],args[1]);
}

}

I kill the process from a script and calling

/bin/kill -s SIGINT <pid>

doesn’t kill the java process for some reason. I thought SIGINT is handled as part of

Signal.handle(new Signal("INT"), handler);

What am i missing here?

Regards
Dheeraj Joshi

  • 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-01T08:16:53+00:00Added an answer on June 1, 2026 at 8:16 am

    I think you need to sent ‘SIGTERM’ (‘kill’ w/o ‘-s’ parameter) for shutdown hook to work.

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

Sidebar

Related Questions

I am creating a small TFTP client server app where server is developed using
Creating a zip file using Send To -> Compressed folder excludes .hg folder on
Creating a server-side socket will fail if I'm trying to use the same port
Creating a table without tbody using javascript createElement/appendChild will not add tbody in Firebug
Creating sprite sheets aka texture atlases rather than using many hundres of individual images
Creating a site in with FrogCMS and using alot of jquery to create an
Creating the closure is easy but using it is confusing for me. Here is
Creating a simple TCP server based on examples but still do not get how
I'm creating a tftp-like program but instead of stop and wait, I'm trying to
Creating My Windows Form Application and using ADO.Net as Data Access layer and SQL

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.