Re: Redhat-devel-list digest, Vol 1 #1017 - 1 msg
mara ailiez sy <[email protected]> Sun, 11 Jan 2004 00:07:33 -0800 (PST)
| Newsgroups | gmane.linux.redhat.devel |
|---|---|
| Message-ID | <[email protected]> |
tnx for ur helo... i will look on that... [email protected] wrote:Send Redhat-devel-list mailing list submissions to [email protected] To subscribe or unsubscribe via the World Wide Web, visit https://www.redhat.com/mailman/listinfo/redhat-devel-list or, via email, send a message with subject or body 'help' to [email protected] You can reach the person managing the list at [email protected] When replying, please edit your Subject line so it is more specific than "Re: Contents of Redhat-devel-list digest..." Today's Topics: 1. Re: help in linux startup process (James Olin Oden) > ATTACHMENT part 3.1 message/rfc822 Date: Sat, 10 Jan 2004 10:54:43 -0500 (EST) From: James Olin Oden To: [email protected] Subject: Re: help in linux startup process On Wed, 7 Jan 2004, mara ailiez sy wrote: > elo... im currently doing my thesis and i want to ask if there is a tutorial available on how to create a startup background process in linux... hope someone could help me out tnx...=) > Don't know if there is a tutorial but its pretty easy. >From shell you use &: $ someprog & Course then its still tied to your tty, so then you add nohup: $ nohup someprog & In all cases the pid of the process is in $! (if I recall correctly check the bash man page). Programatically, you use fork, exec, setsid. In perl it looks like this: use POSIX qw(setsid); $pid = fork(); if($pid < 0) { die "Could not fork()!"; } if($pid == 0) { # # This is child code # Dissassociate from terminal... setsid() # # Either close stdout, stderr and stdin # or send them to /dev/null (this very important). open(STDOUT, ">&/dev/null"); open(STDERR, ">&/dev/null"); open(STDIN, "<&/dev/null); # # Exec the new command (you only need this if you # want to load some other executable). exec('someprog'); # # This won't return } # # Parent code can now do anything it wants. The process # of the backgrounded task is in $pid. ... There are other nuiances, but a good start is reading the man pages on fork, exec, and setsid (for instance, things like signal handling for your backgrounded process). The example above was in perl, but the same system calls exist in C, and the code would look mighty similar. Cheers...james > > --------------------------------- > Do you Yahoo!? > Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes _______________________________________________ Redhat-devel-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/redhat-devel-list --------------------------------- Do you Yahoo!? Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes