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 8455267
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:14:34+00:00 2026-06-10T12:14:34+00:00

I am using a native compiled jsvc to launch a java daemon. I am

  • 0

I am using a native compiled jsvc to launch a java daemon. I am running this on an openSUSE 32 bit vm. The code implements Apache’s daemon interface, and I’m executing the deamon with the following command.

./jsvc -home jre -errfile logs/jsvc.err -pidfile daemon.pid -cp <my_classpath> com.loader.loaderservice.LoaderDaemon

It starts and runs without a problem. I can start the daemon as a normal user and as root. However, when I go to terminate the daemon, jsvc kills the process rather than issuing a stop command.

./jsvc -stop -home jre -outfile logs/jsvc.err -errfile logs/jsvc.err -pidfile daemon.pid -cp <my_classpath> com.loader.loaderservice.LoaderDaemon

The daemon process dies, but does not execute any of its shutdown steps (for example, it should log, mark a record in the db, etc). I get the following in the logs/jsvc.err file, and it doesn’t write any other logs:

Service exit with return value 143

After googling the error, I’m seeing a handful of people who all have seen the same thing, but nowhere can I find a good resolution (http://mail-archives.apache.org/mod_mbox/commons-dev/200401.mbox/%3CPine.GSO.3.96.1040105133739.23375A-100000@merlot.tel.uva.es%3E, http://www.tek-tips.com/viewthread.cfm?qid=1014679, http://threebit.net/mail-archive/tomcat-users/msg03832.html).

UPDATE:
Using Apache’s window’s service launcher (procrun) I am able to start and stop the service without any problems. The problem appears to be only jsvc related, and only on stopping the daemon.

UPDATE 2:
After reading the http://commons.apache.org/daemon/jsvc.html#Starting_jsvc more carefully, I noticed that the stop tag I’m using issues a kill command pn the process via the pid file I specify. It seems that jsvc doesn’t actually stop the daemon gracefully by design. This is consistent with the behavior I’m seeing, as the very verbose stop method isn’t writing any messages out.

-stop        stop the service using the file given in the -pidfile option

New Questions:

  • If my java main has implemented the Apache Daemon interface, how do I issue a ‘stop’ on the running daemon?
  • Do I need something other than jsvc (which seems like it’s only useful for starting or killing the daemon)?
  • 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-10T12:14:36+00:00Added an answer on June 10, 2026 at 12:14 pm

    Ah, ok. It turns out that the jsvc stop command was behaving correctly. I had to dig into the way that processes receive termination messages in Linux/Unix via the kill command. Jsvc issues a kill -15 (which is a soft kill) on the daemon. See: http://commons.apache.org/daemon/ and http://en.wikipedia.org/wiki/Kill_(command) for the description of how unix processes receive messages.

    The real issue was in the construction of the daemon. In my start method, the daemon looped until a shutdown command was issued, which prevented the daemon from giving up control as the daemon child process.

    I had this:

    @Override
    public void start() 
    {
        doStartWork();
        while (isAlive()) 
        {
            Thread.sleep(1000); 
        }
    }
    

    I should have had below, so I could return and allow the daemon thread to receive signals from the OS. See http://commons.apache.org/daemon/jsvc.html#How_jsvc_works, sepcifically the section under: ‘Controlled process:’

    @Override
    public void start() 
    {
        doStartWork();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using the Java Native Interface to include some statically compiled code in
I'm in the process of doing some Java<->.NET interop code using a native library
I've wrote a java code and compiled it. (foo1.6.class) According to my search, my
gcj can compile Java code into native code. I am interested if Java is
E:\Code\Java\JNITest>java test Exception in thread main java.lang.UnsatisfiedLinkError: E:\Code\Java\JNITest\test.dll: Can't load IA 32-bit .dll on
Mono can be compiled to native AOT executable using mkbundle. My question is, how
Using the ndk I have compiled a code written in C. The program is
I have a C++ 'Control Library Project' compiled using /CLR. Inside this project there
I have a Matlab function compiled into C library. I am using this library
I have a native shared library compiled using android-ndk one of the C API

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.