Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C++ and Visual C++ > C++ Programming
| Search | Today's Posts | Mark Forums Read
C++ Programming General discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old September 10th, 2003, 12:54 AM
Registered User
 
Join Date: Sep 2003
Location: , MI, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ohwail
Default Placing processes in the background

Hey there!

    I am new to this forum so bear with me. I am trying to write my own shell for Linux, and so using C I was able to write one which basicly reads in a command with arguments and executes it, however I want to make my shell to automaticlly run processes in the bakground everytime, which should return me to command line everytime I enter a command and not wait for it to be finished. I looked at the different exe() syscalls and didnt see one that will take as an argument and indicator that a particular process should be run in the background. Any pointers here would be helpfull.


Reply With Quote
  #2 (permalink)  
Old September 10th, 2003, 01:05 AM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Maybe you should use fork() to launch a separate child process, and that child process would then exec() your command.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #3 (permalink)  
Old September 10th, 2003, 11:47 AM
Registered User
 
Join Date: Sep 2003
Location: , MI, USA.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to ohwail
Default

Thats the thing I am already using fork() to call a child process to execute my command, but fork() issues a block in which I have to wait until the child is done before control is returned to the parent. I think I need to not include a wait() and trap the signal of the child when its done. Does anyone know how to trap the signal of a terminated child. I am going to palce and example of what I am trying to do. Notice I go back to command prompt after I hit enter and not wait for the grep command to finish executing.

[oci]$ grep back oci.c
[oci]$
[7] 5066
  int i, status, backg, direct;
      backg = 0;
          /*if(!backg)
          backg = 0;
[7] Done grep back oci.c
[oci]$



Reply With Quote




Similar Threads
Thread Thread Starter Forum Replies Last Post
remote processes gobotsoup ASP.NET 2.0 Basics 1 May 6th, 2007 01:50 PM
Checking Processes AggressiveFish Beginning VB 6 0 September 19th, 2006 01:29 PM
Manipulating Processes ? kush28 C# 1 October 26th, 2005 04:49 AM
processes in php Moharo Pro PHP 1 November 10th, 2003 08:47 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.