Currently, if you try to use ctrl-c while python code is running nothing happens. This is not ideal. This change enables users to use ctrl-c while python is running (e.g., when a large disk image is downloading). To do this, we moved the `initSignals` function in gem5 from `main` to the simulate loop. Thus, every time the simulate loop starts (i.e., is called from python) gem5 will install its signal handlers. Also, when the control is returned to python, we put python's default SIGINT handler back. Change-Id: I14490e48d931eb316e8c641217bf8d8ddaa340ed Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
48 lines
1.9 KiB
C++
48 lines
1.9 KiB
C++
/*
|
|
* Copyright (c) 2008 The Hewlett-Packard Development Company
|
|
* All rights reserved.
|
|
*
|
|
* Redistribution and use in source and binary forms, with or without
|
|
* modification, are permitted provided that the following conditions are
|
|
* met: redistributions of source code must retain the above copyright
|
|
* notice, this list of conditions and the following disclaimer;
|
|
* redistributions in binary form must reproduce the above copyright
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
* documentation and/or other materials provided with the distribution;
|
|
* neither the name of the copyright holders nor the names of its
|
|
* contributors may be used to endorse or promote products derived from
|
|
* this software without specific prior written permission.
|
|
*
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*/
|
|
|
|
#ifndef __SIM_INIT_SIGNALS_HH__
|
|
#define __SIM_INIT_SIGNALS_HH__
|
|
|
|
namespace gem5
|
|
{
|
|
|
|
void dumpStatsHandler(int sigtype);
|
|
void dumprstStatsHandler(int sigtype);
|
|
void exitNowHandler(int sigtype);
|
|
void abortHandler(int sigtype);
|
|
void initSignals();
|
|
|
|
// separate out sigint handler so that we can restore the python one
|
|
void initSigInt();
|
|
void restoreSigInt();
|
|
|
|
} // namespace gem5
|
|
|
|
#endif // __SIM_INIT_SIGNALS_HH__
|