Re: Redhat-devel-list digest, Vol 1 #1017 - 1 msg

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



tnx for ur helo... i will look on that...

redhat-devel-list-request@xxxxxxxxxx wrote:
Send Redhat-devel-list mailing list submissions to
redhat-devel-list@xxxxxxxxxx

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
redhat-devel-list-request@xxxxxxxxxx

You can reach the person managing the list at
redhat-devel-list-admin@xxxxxxxxxx

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: redhat-devel-list@xxxxxxxxxx
Subject: Re: help in linux startup process

On Wed, 7 Jan 2004, mara ai! liez 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
Redhat-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-devel-list


Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux