Sponsored Content
Top Forums Programming want to run a function in background Post 96545 by linuxpenguin on Friday 20th of January 2006 07:32:50 PM
Old 01-20-2006
ok bankpro, fork is just a diversion from the main program. now you dont want it to return to main, then you do one thing, put the function part as a different program. and instead of calling the function, call "exec" function with the program name containing your function as the argument.
and since you want to make it run in background, you have to make the new program called in child using fork, as a daemon program.
I am sure you will find code snippets for a daemon program on the forum, if you do a search, if not check out this link
http://www.geocities.com/hemantborole/
click on KnowledgeBank, on the next page, click on C under My Programs, and in the list of programs, click on daemon.c to see the sample of the daemon process.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

subshell & background function

Hello all, Can someone explain to me the advantage between using subshell over a function call in scripts? To me these are the same. Am I wrong to think this? (4 Replies)
Discussion started by: larry
4 Replies

2. Shell Programming and Scripting

run a shell in the background

How can I run a shell in the background? cat test.sh #!/bin/sh sleep 600 Thank u very much indeed! (2 Replies)
Discussion started by: GCTEII
2 Replies

3. Shell Programming and Scripting

how to run script at background

Hi all, I have a script like: echo Please input list file name: read listn for file in `cat $listn.txt` do send_file $file done normally, I will run the script like: :. resendfile Please input list filename: list1 #Then, the script will resend all file from the list1. However,... (4 Replies)
Discussion started by: happyv
4 Replies

4. UNIX for Dummies Questions & Answers

can we run ssh2 in background

Hi, I was trying to run ssh2 command in background... but i got follwoing error message saying that process has been stopped.. + Stopped(SIGTTOU) Anyone have any idea about this??? Appreciated your help.. (3 Replies)
Discussion started by: pvamsikr
3 Replies

5. Shell Programming and Scripting

A question about the PID of a background function

Dear all, I'm writing a KornShell script that calls inside it a function in background mode #!/bin/ksh function myfunction { . . .} myfunction |& . . . How can I capture the PID of the function myfunction that runs in background? Thanks in advance :) (2 Replies)
Discussion started by: dariyoosh
2 Replies

6. Shell Programming and Scripting

background scripts run-help

Looking for a logic where say i have a script called parent_script which is used to call other 4 to 5 child scripts in background as.. cat parent_script # containing 65 lines 1 2 .. 35 while read child_script 36 do 37 ./child_script_name& 38 done< ${SCRIPT_LISTS} 39 40 # Need to have... (2 Replies)
Discussion started by: michaelrozar17
2 Replies

7. Shell Programming and Scripting

Run wineconsole in background

Hello everybody, I'm making a script for running a .bat process on wineconsole, but I want that wineconsole doesn't show up when I call it from the script. The script is named "reset" and it looks like this: When I execute it, it will show up the wineconsole window on top, and that is... (3 Replies)
Discussion started by: taurokpo
3 Replies

8. Shell Programming and Scripting

how to run in background mode.

Hi All, i'm a newbie here, i'm just wondering in how do i run my script in background then echo it if it's done. Please advise, Thanks, -nik (1 Reply)
Discussion started by: nikki1200
1 Replies

9. Shell Programming and Scripting

How to run Background process one after another

Hii Friends, I am using Perl CGI. I am running A SCP Command via Perl CGI in Background. Like system("scp -r machinename:/PathOfFile/ /Path/WhereToCopyIt/ &) This Copy Process takes some times lets say 15 min. Now I want When This copy process gets complete then send me... (5 Replies)
Discussion started by: Navrattan Bansa
5 Replies

10. Shell Programming and Scripting

Execute a function in background and then suspend it

Here is some back ground on the script. The script is to poll an arbitrary number of DB's. To do this I am creating a function that takes the file_path to the DB and the min poll interval as arguments. The function will be called for each DB and then ran in the background. The function I was... (6 Replies)
Discussion started by: ryandavison
6 Replies
IREXEC(1)								FSF								 IREXEC(1)

NAME
irexec - run programs with one button press SYNOPSIS
irexec [options] [config_file] DESCRIPTION
This program lets you execute arbitrary commands on an IR signal decoded by lircd, the LIRC daemon. You can give irexec a command line parameter which has to be a name of a valid config file. If no command line parameters are given irexec reads the default config file which is usually ~/.lircrc. If irexec executes a program it will wait until this program terminates. So append a '&' to the command string if you don't want that. The config string consists of the command to be run. -h --help display usage summary -v --version display version -d --daemon run in background -n --name use this program name OPTIONS
If you add the --daemon option irexec will fork to background. That way you can easily start irexec from an init script. In this case you should specify a config file on the command line as irexec won't be able to find your home directory. Potential uses are shutting down the computer, starting a dial-up connection etc. NOTE
If you start irexec, it reads your ~/.lircrc and reacts only on prog= entries that point to irexec. If you have included more than one pro- gram in your .lircrc, then start all these programs, they react itself only to their according entries in .lircrc. SEE ALSO
The documentation for lirc is maintained as html pages. They are located under html/ in the documentation directory. irexec 0.8.7pre1 May 2010 IREXEC(1)
All times are GMT -4. The time now is 10:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy