Visit Jeremy's Blog.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 09-20-2004, 08:35 PM   #1
Registered: Dec 2003
Location: NC, US
Distribution: Novell Linux Eval (2.6.5)
Posts: 240

Rep: Reputation: 30
code that send a process to the background

What function in C that sends a process to the background?
Old 09-20-2004, 09:28 PM   #2
Senior Member
Registered: Jun 2004
Posts: 2,553

Rep: Reputation: 52
check out sys/resource.h.
there are a few functions in there dealing with this but the others deal with classes of processes

int nice (int increment);

returned failure is -1
otherwise it returns new nice value
only root processes can lower nice but any thing can raise it (send itself further into background)
default value is 0
the spread of values is set by the kernel but generally
20 is most toward background (or 10)
PRIO_MIN/PRIO_MAX is the spread
negative values are less nice
Old 09-20-2004, 09:58 PM   #3
Senior Member
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
/* Jump into background */
Old 09-21-2004, 05:53 PM   #4
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
To make a program go really into background, i.e. become a "daemon", you can just call deamon() (see "man 5 daemon")
#include <stdio.h>
#include <unistd.h>

int main()
    if(daemon(0,0) < 0) {
        return 1;

    /* ... */

    return 0;
Note that this makes it the program go into background to never come back. It completely detaches from the terminal, and looses stdin, stdout and stderr. It's not what the shell does when ending a command with "&". (or was it that what you were looking for?)

Last edited by Hko; 09-21-2004 at 06:09 PM.
Old 11-29-2010, 03:11 PM   #5
LQ Newbie
Registered: Oct 2010
Posts: 2

Rep: Reputation: 0

pleaze can help me how to send process from frontground to background
and stop by using ctrl+z pleace i need code in
languge c
Old 11-29-2010, 03:20 PM   #6
LQ Guru
Registered: Nov 2003
Location: Canada
Distribution: Slackware
Posts: 7,565

Rep: Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914Reputation: 2914


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how a father process know which child process send the signal SIGCHLD icoming Programming 10 07-20-2010 07:26 AM
really background a process Henster Linux - Newbie 1 07-01-2005 05:29 AM
is there a system call to send process to run in the background? feetyouwell Programming 4 10-01-2004 04:58 AM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 12:27 AM
send process to background radam Linux - General 6 07-13-2004 04:33 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:13 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration