12-02-2003
what about writing a ftp daemon process.
your daemon will have 2 forks, (as per the standard daemon in stevens) the second child will exec your ftp program and before that it will catch the sighup or whatever signals you want.
Tell me if you need more help, this one interests me!
10 More Discussions You Might Find Interesting
1. Programming
Hi All,
The scenario is like this:
There is a process say "A" which create a child process say "B" if some condition is true and process "A" terminates. "B" invokes some C program say "C" using 'execl' function. The job of program "C" is to keep polling the server until the server will be up.... (2 Replies)
Discussion started by: ranjkuma692
2 Replies
2. Shell Programming and Scripting
hi
what is the shell programming code to know the number of processes currently running on the machine & information about those processes.
Another one is the configuration and usage of the UNIX file system?
requesting all for help.
thanks (1 Reply)
Discussion started by: moco
1 Replies
3. UNIX for Dummies Questions & Answers
Hi all,
When I issued command ps -ef|grep Vinay in a UNIX machine,
I got the following
Vinay 22491 1 255 Jun 18 ? 294248:53 -sh
Vinay 26628 1 255 Jun 18 ? 294237:33 -sh
Could you tell me what all process is running ? Please explain each of the fields.
Thanks... (4 Replies)
Discussion started by: coolbhai
4 Replies
4. Programming
Hi All,
I am new to Linux and i need your for a program which makes the exact copy of the running process. I have got some codes but it only works for the first command and will not work for subsequent commands. Means it works for "ps" but will not work for "ps u". I have changed the code to... (1 Reply)
Discussion started by: subhash007
1 Replies
5. Programming
I'm trying to do a program that makes activate an signal (SINGALARM) when the next child of a son appears but this not works.
I have to caught the next child o the other (pid), to send a singnal which inform a menssage.
It's anything worng in the code?
thanks.
the code:
#include... (2 Replies)
Discussion started by: marmaster
2 Replies
6. UNIX for Dummies Questions & Answers
I have been having some trouble trying to get some code working, so I was wondering...what system calls are required to execute a different program from an already running process? (1 Reply)
Discussion started by: Midwest Product
1 Replies
7. Shell Programming and Scripting
Hi, I would like to ask, if is it possible to quit running loop in the script any other way than catching the trap signal. Ctrl-C ends only current running instance of process but not whole script. Any clues? (3 Replies)
Discussion started by: smoofy
3 Replies
8. Shell Programming and Scripting
I'm trying to create a ksh script to do the following:
1) Ask the user what process they want to search for.
2) Have the script read the input as a variable and use it to search for the process.
3) Display the current time & date, the working directory of the process, and finally display the... (6 Replies)
Discussion started by: seekryts15
6 Replies
9. Shell Programming and Scripting
All,
1.What is the unix comand used for all current running process (Including All current running processes Parent ->child->subchild process)
2.If child and subchild processes are running then what is the unix command to kill parent and its all child subchild processes in UNIX.
Kindly... (7 Replies)
Discussion started by: skp
7 Replies
10. Shell Programming and Scripting
Hi,
i need to list the processes running only under current logged in user.
EX:
$ whoami
oraaqw
$ ps -ef | grep tnslsnr
oraaqw 11403300 19267592 0 09:14:47 pts/3 0:00 grep tnslsnr
oraaqw 15794208 1 0 Jan 14 - 11:59... (6 Replies)
Discussion started by: aravindadla
6 Replies
LEARN ABOUT MOJAVE
daemon
DAEMON(3) BSD Library Functions Manual DAEMON(3)
NAME
daemon -- run in the background
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
int
daemon(int nochdir, int noclose);
DESCRIPTION
The daemon() function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons.
The fork(2) system call is used; see CAVEATS below about the environment after a fork() (without a corresponding call to one of the exec rou-
tines). On Mac OS X, the use of this API is discouraged in favor of using launchd(8).
Unless the argument nochdir is non-zero, daemon() changes the current working directory to the root (/).
Unless the argument noclose is non-zero, daemon() will redirect standard input, standard output, and standard error to /dev/null.
RETURN VALUES
The daemon() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate
the error.
ERRORS
The daemon() function may fail and set errno for any of the errors specified for the library functions fork(2) and setsid(2).
SEE ALSO
fork(2), launchd(8), setsid(2), sigaction(2)
HISTORY
The daemon() function first appeared in 4.4BSD.
CAVEATS
There are limits to what you can do in the child process. To be totally safe you should restrict yourself to only executing async-signal
safe operations (see sigaction(2)) until such time as one of the exec functions is called. All APIs, including global data symbols, in any
framework or library should be assumed to be unsafe after a fork() unless explicitly documented to be safe or async-signal safe. If you need
to use these frameworks in the child process, you must exec. In this situation it is reasonable to exec yourself.
Unless the noclose argument is non-zero, daemon() will close the first three file descriptors and redirect them to /dev/null. Normally,
these correspond to standard input, standard output, and standard error. However, if any of those file descriptors refer to something else,
they will still be closed, resulting in incorrect behavior of the calling program. This can happen if any of standard input, standard out-
put, or standard error have been closed before the program was run. Programs using daemon() should therefore either call daemon() before
opening any files or sockets, or verify that any file descriptors obtained have values greater than 2.
The daemon() function temporarily ignores SIGHUP while calling setsid(2) to prevent a parent session group leader's calls to fork(2) and then
_exit(2) from prematurely terminating the child process.
BSD
June 9, 1993 BSD