LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-06-2004, 02:41 PM   #1
linuxanswer
Member
 
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Rep: Reputation: 15
background code


anyone know how implemente in c, the backgorund execution like in bash with the & operator at last ? For example i code a program that once it's started, return me the shell, and when it finish, warn me about the end execution. tnx in advance
 
Old 04-06-2004, 02:55 PM   #2
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
Why not just run your program IN the background from bash (using the & symbol as usual) and write it so that just before it finishes it either prints something to the shell to alert you, or prints the bell symbol (\a?) so the PC Speaker beeps?
 
Old 04-06-2004, 03:06 PM   #3
linuxanswer
Member
 
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Original Poster
Rep: Reputation: 15
too simple, komakino, too simple : )
 
Old 04-06-2004, 04:03 PM   #4
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
Maybe you could create a program with two threads, one that spawns a shell, and another with your program code. Then when your program thread is done, it gives you a warning, then after a time interval, kills the shell thread? The only real advantage of this would be having the option of implementing a program switch so you can tell the program to run interactively, or not. Komakino's answer is the simplest and fastest to implement though.
 
Old 04-06-2004, 04:11 PM   #5
linuxanswer
Member
 
Registered: Oct 2003
Distribution: woodY 3.0 stable
Posts: 61

Original Poster
Rep: Reputation: 15
komakino, one question, what's (\a?) ? How can i implement this ?
 
Old 04-06-2004, 09:45 PM   #6
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
\a is a printf escape sequence, it produces a beep. You use it like:

Code:
printf("\a")   ;
Depending on your terminal, \a will produce a beep or visual alert (like a screen flash).
 
  


Reply



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
code that send a process to the background feetyouwell Programming 5 11-29-2010 03:20 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Change background in solaris and Xterm background also EvilAngel Solaris / OpenSolaris 2 01-31-2005 11:25 AM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 12:27 AM
PHP code did not create a cookie and it did not changed the background and text color Linh Programming 5 07-29-2004 10:15 PM

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

All times are GMT -5. The time now is 07:38 PM.

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
Open Source Consulting | Domain Registration