Date: | Wed, 12 Apr 2006 15:28:18 +0300 |
From: | Diomidis Spinellis <dds@aueb.gr> |
Organization: | Athens University of Economics and Business |
User-Agent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060130 SeaMonkey/1.0 |
MIME-Version: | 1.0 |
Newsgroups: | comp.unix.programmer |
Subject: | Re: _pause() and _continue() |
References: | <1144804741.930960.110640@v46g2000cwv.googlegroups.com> <e1i4o7$4ph$1@volcano1.grnet.gr> <1144838857.141207.276890@i39g2000cwa.googlegroups.com> |
In-Reply-To: | <1144838857.141207.276890@i39g2000cwa.googlegroups.com> |
Content-Type: | text/plain; charset=ISO-8859-1; format=flowed |
Content-Transfer-Encoding: | 7bit |
DaVinci wrote:
> Diomidis Spinellis wrote:
>> DaVinci wrote:
>>> I am writing a ncurses game,ping-pong,
>>> void _pause()
>>> //when the user press 'p',the game will pause
>>> {
>>> //??how to implement?
>>> }
>> Simply enter a state where you read and discard characters, until you
>> get an EOF or a 'p'.
>
> #include <signal.h>
> #include <unistd.h>
> #include <iostream>
> void sig_cont(int signo)
> {
> std::cout<<"sig_cont ()"<<std::endl;
> return ;
> }
>
> int main()
> {
> signal(SIGCONT,sig_cont);
> char ch;
> while(1)
> {
> signal(SIGCONT,sig_cont);
> ch = getchar();
> if(ch == 'p')
> {
> pause();
> }
> else if(ch == 'c')
> {
> kill(getpid(),SIGCONT);
> std::cout<<"send signal SIGCONT"<<std::endl;
> }
> else
> {
> std::cout<<"hello world"<<std::endl;
> }
> }
>
> }
> when I programme had paused ,how can I wake up it? how can I make it
> continue to run?
>
Don't pause the program with SIGTSTP, because then only another external
process can send you a SIGCONT.
--
Diomidis Spinellis
Code Quality: The Open Source Perspective (Addison-Wesley 2006)
http://www.spinellis.gr/codequality
Newsgroup comp.unix.programmer contents
Newsgroup list
Diomidis Spinellis home page
Unless otherwise expressly stated, all original material on this page created by Diomidis Spinellis is licensed under a Creative Commons Attribution-Share Alike 3.0 Greece License.