LinuxQuestions.org
Register a domain and help support LQ
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
 
LinkBack Search this Thread
Old 08-17-2006, 06:22 PM   #1
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,024

Rep: Reputation: 197Reputation: 197
C++: Way to have System run in background?


I'm using System() to play a sound file and make a xmesage box. Problem is that my program will wait until I have pressed the ok button before continuing. This is a calendar/reminder program and if I have 2 alarmed events the 2nd will not be processed because the main prog is waiting for the first to end.

So is there any way around this? I tried adding '&' to the end of the System call string but didn't work.

Code:
 void do_event_alarm(int ev)
 {
     string str="xmessage -center "+events[ev].summary+" 2>/dev/null";
     string sound_str="aplay -q "+soundfile;
     string start=events[ev].start;
     if ( soundfile!="" ) system(sound_str.c_str());
     if ( start!="" )
         cout<<start.substr(6,2)<<"/"<<start.substr(4,2)<<"/"<<start.substr(0,4)<<endl;
     cout<<events[ev].summary<<endl;
     cout<<events[ev].description<<endl;
     system(str.c_str());
 }
 
Old 08-17-2006, 06:30 PM   #2
sirclif
Member
 
Registered: Sep 2004
Location: south texas
Distribution: fedora core 3,4; gentoo
Posts: 192

Rep: Reputation: 30
have you tried putting a '&' at the end of your string?
 
Old 08-17-2006, 08:15 PM   #3
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,024

Original Poster
Rep: Reputation: 197Reputation: 197
Yes I tried that but didn't have any effect
 
Old 08-17-2006, 08:29 PM   #4
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,024

Original Poster
Rep: Reputation: 197Reputation: 197
Just tried it again and it works. There is a problem elsewhere in the code stopping 2 events at same time occuring.

Thanks
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are 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
is there a system call to send process to run in the background? feetyouwell Programming 4 10-01-2004 05:58 AM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 01:27 AM
run process in background using system calls indian Programming 2 08-10-2004 06:03 PM
Run programs in background... Cybers19 Linux - Newbie 1 06-02-2004 04:54 AM


All times are GMT -5. The time now is 11:23 AM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration