You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
Required fields*
- 9No need for the Java to write the PID, the script can do it as well (echo $! > /var/run/my.pid) Also, since usually only root can write to /var/run you can have the shell script running as root and the daemon run as another user.David Rabinowitz– David Rabinowitz2009-04-06 10:58:42 +00:00Commented Apr 6, 2009 at 10:58
- Except you can't change uid or euid in java, so you have to do it from the shell, with sudo... it's a bit of a pain if you ask me. It's easier to have /var/run and var/log writable to the user you run as...Varkhan– Varkhan2009-04-06 17:01:18 +00:00Commented Apr 6, 2009 at 17:01
- 3Also, the rationale for having Java write the pid file / lock file is to have a mean to know whether the initialization phase of the daemon completed successfully (by writing at the end of that phase).Varkhan– Varkhan2009-04-06 17:41:04 +00:00Commented Apr 6, 2009 at 17:41
- 1This answer is useless. You want to do the fork AFTER the sockets are created. This just detaches the process from the shell, it's a different thing altogether.LtWorf– LtWorf2017-07-21 09:10:03 +00:00Commented Jul 21, 2017 at 9:10
- The cop-out option won't work -- the thread id is almost certainly not the same as the process id.Luke Hutchison– Luke Hutchison2020-08-06 07:15:19 +00:00Commented Aug 6, 2020 at 7:15
| Show 1 more comment
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. python-3.x), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-java