Ok guys so I have my first dummy shell almost done except for one tiny part: I do not know how to run a process in the background, from the code!
I already know how to do that in a normal shell:
$ program &
However, no clue when it comes to how to program that thing.
A very abstract description of how my program works would be the following:
Ok, I got all of that working perfectly. I just need to find out a way for it to read the & as a signal saying "run this process in the background!" But I have no idea how.
I understood your idea.You want to run the process as background inside the code.But,I don't know which process you want to run.You can pass the & as an argument to this program from command line by using "&".You can get the argument by using argv[1].
If you want to run the process background programmatically , then you must make the process as a daemon.
I :
* The first step is that change the current directory as root "/" because it provide the
facility to do all the operation from the root
* If you want to mount a file system then you are unable to do this with out changing cur_dir into a root dir * what are all the path name you planned to give that should be in a absolute path name
II:
* Create a process and kill the parent of that process
* It will make the living process ( child ) as a child of init() and its process id will become 1
* Though a we never need a parent for a daemon
III :
* Daemon should be a session leader
* This can be achieved using setsid() in C
IV :
* We don't need an interaction of user for daemon process
* So we close all the descriptor
* We should assure that no other file descriptor would be assign for this process
V :
* Output and the monitoring the daemon will be done using a log files
* It is better to log the information in a /var/log/ directory structure
VI :
* Daemon should always in a running state
* So we should secure the daemon from the signals
* We should ignore all the signals except SIGHUP
* As a convention SIGHUP uses for reading configuration file
VII :
* Have a termination handler
* We should do some operation whenever we terminate the daemon
* Like releasing the memory closing the configuration file etc .
How do I list the process in a Unix based system which are running in background?
The following are options that I'm aware of, but they may not be appropiate.
a. using ps -ef , and getting records of processes for which STATUS='S'(uninterruptible sleep)
b. using jobs -l, and filtering... (5 Replies)
Hi,
I have a schell script parent.ksh from which I am calling three background processes a.ksh,b.ksh and c.ksh. Once these three processes completes the next step in parent.ksh should execute. How to achieve this?
Please help me....
Thanks... (1 Reply)
Hi,
I need to establish a procedure that will start an application in background each time my remote Solaris server is (re)started. This would be a kind of daemon. I am no sysadmin expert, so I am looking for pointers.
How should I proceed? What are the main steps?
Thanks,
JVerstry (9 Replies)
Hi,
Inorder to improve the performance, I am trying to execute my command as a background process..
For eg: To zip large numbers of files present in a directory instead of using a single process, i do follow the below method:
gunzip -c > / &... (3 Replies)
I've got a bit of code I'm trying to work on...
What i want to happen is ... at all times have four parallel mysql dump and imports running.
I found the follow code snippet on the forum and modified it to work
by starting four concurrent processes but it waits until all four are done before... (7 Replies)
I have installed oracle 10g on suse sles9. I do not see oracle background processes.
ps -ef|grep ora_ gives me environment variables junk.
ps -ef|grep smon does not show anything however database is up and running.
Any idea how to tweak that? (1 Reply)
Hi!
First of all, let me warn you I'm quite new to the world of LINUX and Operating Systems understanding, so that's why I pose these newbie and stupid qustions...
Anyway, I'm trying to build my own simple shell in C and I'm getting some problems in implementing the background process ('&')... (10 Replies)
Hey guys,
I am writing a very simple dummy shell in C++ and I am having trouble getting a process to run in the background. First of all, the shell has to recognize when I input a "&" at the end of the command, then it has to stick it in the background of the shell.
I understand that if I want... (6 Replies)
hi there,
here's what i need in my korn-shell:
... begin korn-shell script
... nohup process_A.ksh ; nohup process_B.ksh &
... "other stuff"
... end lorn-shell script
in plain english i want process A and process B to run in the background so that the script can continue doing... (6 Replies)
How do you capture the return code from a background process?
I am dumping data to a fifo and then processing it in a c program.
I need to know that the sql finished successfully to ensure no missing data. Thanks.
ex.
sqlplus user/password < get_data.sql > data_fifo.txt &
bin/process_data... (2 Replies)