How to make an application to prevent itself from launching from the command line?
I have a binary which should be launched by a daemon; but when somebody tries to launch the binary from command line, I should error out stating "cannot be launched from command line".
Tried googling but in vain.
boomerang2711
0
Newbie Poster
Recommended Answers
Jump to PostMy first approach would probably be to check the parent process and kill the program if the parent is a shell, like bash or csh.
Jump to PostAnother approach would be to see if stdin is attached to a real terminal. A process that is spawned by a daemon would have no stdin device, or it would be /dev/null.
All 5 Replies
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
boomerang2711
commented:
never mind.. i got it!
+0
boomerang2711
0
Newbie Poster
rubberman
1,355
Nearly a Posting Virtuoso
Featured Poster
boomerang2711
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.