LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 03-23-2004, 09:05 PM   #1
syberdave
LQ Newbie
 
Registered: Oct 2003
Distribution: slackware
Posts: 13

Rep: Reputation: 0
run command in background using C


Hello,
Does anyone know how to run commands in the background using system() ?
I would like the code to continue running without waiting for the program to exit.
Thanks in advance,
Dave.
 
Old 03-23-2004, 09:24 PM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Code:
int main(void)
{
  if(!fork())
  {
     system("my_command_that_runs_in_the_background");
     return 0;
  }

// Rest of your program goes here
}
 
Old 03-23-2004, 09:31 PM   #3
syberdave
LQ Newbie
 
Registered: Oct 2003
Distribution: slackware
Posts: 13

Original Poster
Rep: Reputation: 0
Thanks a million!
 
Old 04-03-2004, 07:43 AM   #4
ayman.s
LQ Newbie
 
Registered: Apr 2004
Location: Cairo
Posts: 3

Rep: Reputation: 0
Smile Need help....

Hello there:

itsme86: i use the code u written above with rsh command "rsh ip userasswd command" and was compiled successfuly but when i opened the binary file with editor "vi or kwrite" the user and passwd was appeared!!!!!!!!!
plz could u tell me how to prevent this????

thanks alot

 
  


Reply


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 to run a process in the X background sh4d0w13 Linux - General 6 09-12-2005 03:54 PM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 01:27 AM
Run a program in the background??? KaptinKABOOM Linux - Software 5 07-06-2004 07:40 AM
Run programs in background... Cybers19 Linux - Newbie 1 06-02-2004 04:54 AM
How to run a bash command in the background from perl script professorfrink Programming 3 11-13-2003 04:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:28 AM.

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