Sponsored Content
Full Discussion: How to write daemon?
Top Forums Programming How to write daemon? Post 90074 by Perderabo on Friday 18th of November 2005 01:33:34 AM
Old 11-18-2005
I guess that either technique presented in those links is good enough, but I have to say that there is some room for improvement. Both of these techniques are relying on the parent to not make strange mistakes prior to invoking the daemon. We can do a better job of protecting ourself from a insane or hostile parent. By using two forks separated by a setsid() we can create a process that is guaranteed to not have a controlling terminal or even have the ability to accidentally acquire one. I kinda like the idea of closing all possible fd's, but using gettablesize sabotages the idea. gettablesize is basicly a getrlimit(RLIMIT_NOFILE) and is returning the soft limit. You can open a file and then set the soft limit lower...the file won't close or anything. And if the total number of open file is low, you can still open new files. Using sysconf() can avoid that.

Here is a link that gets all of this right 1.7 How do I get my program to act like a daemon? This link is from the Usenet comp.unix.programmer FAQ. From the same FAQ, also see Daemon utility functions. In fact, see the entire FAQ. The whole thing is excellent, despite being a little dated.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to write a daemon in Unix?

Hi I have a directory where sometimes a file will come (in a name format say file001.txt). I want to run a job (.ksh file) as soon as a new file comes into the directory. How can I write a shell script which will run in the background and monitor arrival of new file in the directory? ... (11 Replies)
Discussion started by: sbasak
11 Replies

2. UNIX for Dummies Questions & Answers

How to write Pro*C daemon process using multithreading?

Hello, I am new to this forum and this is my first post here... I have never worked on either Pro*C or Multithreading..Now, i have to write a Pro*C, Multithreading daemon process.. I dont know where to start.. Can anybody help me with examples? 1. need to write a Pro*C multithreading... (0 Replies)
Discussion started by: kachiraju
0 Replies

3. Shell Programming and Scripting

Find all files with group read OR group write OR user write permission

I need to find all the files that have group Read or Write permission or files that have user write permission. This is what I have so far: find . -exec ls -l {} \; | awk '/-...rw..w./ {print $1 " " $3 " " $4 " " $9}' It shows me all files where group read = true, group write = true... (5 Replies)
Discussion started by: shunter63
5 Replies

4. Shell Programming and Scripting

How to write daemon in UNIX

Hi Guys, I hope this is the right forum to post this. I have a directory where files will be dumped at any time of the day and I want to run scripts as soon as new files come into the directory. How can I write a daemon that detects when new files have been uploaded to the directory? ... (1 Reply)
Discussion started by: regie101
1 Replies

5. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

6. Programming

Write-Write on a socket

Can anyone tell what happens if each end writes at the same time on the same socket ? - if one of them issues a read() after write() has completed, will it record into the buffer what the other sent ? ex. e1 writes to e2 - - - while - - - e2 writes to e1 (at the same time) e1 read () - what... (1 Reply)
Discussion started by: gendaox
1 Replies

7. Shell Programming and Scripting

Is it possible to write write multiple cronjobs in shellscript??

Hi All, I need the answer of below question? 1) How to write multiple cronjobs in shellscript? Is there any way or we cant write in shellscript... Regards, Priyanka (2 Replies)
Discussion started by: pspriyanka
2 Replies

8. Programming

Interactive Python 3.5+ sys.stdout.write() AND sys.stderr.write() bug?

(Apologies for any typos.) OSX 10.12.3 AND Windows 10. This is for the serious Python experts on at least 3.5.x and above... In script format sys.stdout.write() AND sys.stderr.write() seems to work correctly. Have I found a serious bug in the interactive sys.stdout.write() AND... (2 Replies)
Discussion started by: wisecracker
2 Replies

9. UNIX for Beginners Questions & Answers

How to write a daemon script?

My requirement is to run two scripts simultaneously. Let say, script1.ksh is running in a loop : example: script1.ksh is: for i in 1 2 3 do script2.ksh 1 & #psedu code which is required to write here # if script 2.ksh is running, execute a script3.ksh (which actually check the... (2 Replies)
Discussion started by: sumitc
2 Replies
QT2KDOC(1)						     KDOC Documentation System							QT2KDOC(1)

NAME
qt2kdoc -- Generates cross-reference file suitable for use with KDOC from Qt Toolkit HTML documentation. SYNOPSIS
qt2kdoc [-u URL] [-o <destdir>] [-z] <path to qt html> DESCRIPTION
qt2kdoc generates a kdoc(1) cross-reference file from the classes.html file that is included with the Qt GUI Toolkit HTML documentation. The resulting file can be used to cross-reference documentation generated with KDOC for other classes with the Qt HTML documentation. OPTIONS
--url <url>, -u <url> The URL by which the Qt documentation can be accessed. This will allow other libraries to link to the Qt documentation. --outdir <path>, -o <path> The directory where the generated index file will be written. --compress, -z Compress the generated index with gzip. KDOC can read these compressed index files. EXAMPLES
qt2kdoc -u "http://www.mydomain/src/qthtml/" $HOME/web/src/qthtml ENVIRONMENT
KDOCLIBS If set, it is used as the default output path. It is overridden by the --outdir option. FILES
classes.html, functions.html The files from which information about the Qt library is read. They are parsed by qt2kdoc. qt.kdoc A kdoc(1) cross-reference file that will be generated by qt2kdoc and can be used to link documentation generated by kdoc with the Qt documentation. SEE ALSO
This script is a utility for kdoc(1). BUGS
Dependent on format of Qt documentation. AUTHOR
Sirtaj S. Kang <taj@kde.org>, 1998. 2.0a54 2002-03-18 QT2KDOC(1)
All times are GMT -4. The time now is 10:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy