summaryrefslogtreecommitdiff
path: root/rts/posix/Signals.c
Commit message (Collapse)AuthorAgeFilesLines
* Make `PosixSource.h` installed and under `rts/`John Ericson2021-08-091-1/+1
| | | | | | is used outside of the rts so we do this rather than just fish it out of the repo in ad-hoc way, in order to make packages in this repo more self-contained.
* Move ioManager{Start,Wakeup,Die} to internal IOManager.hDuncan Coutts2021-01-251-0/+1
| | | | | | | | Move them from the external IOInterface.h to the internal IOManager.h. The functions are all in fact internal. They are not used from the base library at all. Remove ioManagerWakeup as an exported symbol. It is not used elsewhere.
* rts: don't use siginterrupt (#19019)Sylvain Henry2020-12-111-5/+1
|
* Mitigate data races in event manager startup/shutdownwip/tsan/event-mgrBen Gamari2020-10-241-20/+28
|
* rts: Ensure that sigaction structs are initializedBen Gamari2020-04-221-2/+3
| | | | | | I noticed these may have uninitialized fields when looking into #18037. The reporter says that zeroing them doesn't fix the MSAN failures they observe but zeroing them is the right thing to do regardless.
* A few typofixesGabor Greif2019-01-231-1/+1
|
* Finish stable splitDavid Feuer2018-08-291-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Long ago, the stable name table and stable pointer tables were one. Now, they are separate, and have significantly different implementations. I believe the time has come to finish the split that began in #7674. * Divide `rts/Stable` into `rts/StableName` and `rts/StablePtr`. * Give each table its own mutex. * Add FFI functions `hs_lock_stable_ptr_table` and `hs_unlock_stable_ptr_table` and document them. These are intended to replace the previously undocumented `hs_lock_stable_tables` and `hs_lock_stable_tables`, which are now documented as deprecated synonyms. * Make `eqStableName#` use pointer equality instead of unnecessarily comparing stable name table indices. Reviewers: simonmar, bgamari, erikd Reviewed By: bgamari Subscribers: rwbarton, carter GHC Trac Issues: #15555 Differential Revision: https://phabricator.haskell.org/D5084
* Remove markSignalHandlersÖmer Sinan Ağacan2018-04-161-10/+0
| | | | | | | | | | | | It's no-op on all platforms Reviewers: bgamari, simonmar, erikd, dfeuer Reviewed By: dfeuer Subscribers: dfeuer, thomie, carter Differential Revision: https://phabricator.haskell.org/D4588
* rts: Label all threads created by the RTSBen Gamari2017-10-161-7/+10
| | | | | | | | | | Reviewers: austin, erikd, simonmar Reviewed By: simonmar Subscribers: pacak, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D4068
* Use SIGQUIT for DWARF backtraces instead of SIGUSR2Ben Gamari2017-09-251-6/+6
| | | | | | | | Reviewers: austin, erikd, simonmar Subscribers: NicolasT, rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3979
* rts: Print message before SIGUSR2 backtraceBen Gamari2017-09-131-0/+1
| | | | | | | | Reviewers: austin, erikd, simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3942
* Prefer #if defined to #ifdefBen Gamari2017-04-281-11/+11
| | | | Our new CPP linter enforces this.
* Use C99's boolBen Gamari2016-11-291-5/+5
| | | | | | | | | | | | Test Plan: Validate on lots of platforms Reviewers: erikd, simonmar, austin Reviewed By: erikd, simonmar Subscribers: michalt, thomie Differential Revision: https://phabricator.haskell.org/D2699
* Spelling in comment onlyGabor Greif2016-11-181-1/+1
|
* Fix detection and use of `USE_LIBDW`Erik de Castro Lopo2016-06-011-1/+1
| | | | | | | | | | | | Test Plan: Configure/build with and without --enable-libdw Reviewers: trofi, hvr, austin, simonmar, bgamari Reviewed By: bgamari Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2276
* rts: Replace `nat` with `uint32_t`Erik de Castro Lopo2016-05-051-2/+2
| | | | | | | | | | | | The `nat` type was an alias for `unsigned int` with a comment saying it was at least 32 bits. We keep the typedef in case client code is using it but mark it as deprecated. Test Plan: Validated on Linux, OS X and Windows Reviewers: simonmar, austin, thomie, hvr, bgamari, hsyl20 Differential Revision: https://phabricator.haskell.org/D2166
* rts: Split up Itimer.cBen Gamari2016-05-011-0/+29
| | | | | | | | | | | | | | | | | This shouldn't have any functional changes. It merely splits up what are essentially three distinct codepaths which are melding together with CPP. At the moment I merely #include the implementation to use with CPP although this really feels very yucky. Reviewers: erikd, austin, simonmar Reviewed By: simonmar Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D2130
* Libdw: Fix symbol namingBen Gamari2015-11-011-5/+5
| | | | RTS convention is to use camel-case.
* Signals: Ensure libdw session is freedBen Gamari2015-10-311-0/+1
|
* Signals: Always install SIGUSR2 handlerBen Gamari2015-10-181-2/+0
| | | | Even if libdw isn't available.
* Signals: Print backtrace on SIGUSR2Ben Gamari2015-10-171-0/+30
| | | | | | | | | | | | | | | This uses the backtrace support introduced in D1196 to provide backtraces from Haskell processes when SIGUSR2 is thrown. Test Plan: Need to add a test. Reviewers: scpmw, simonmar, Tarrasch, austin Reviewed By: austin Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D1197
* RTS/IOManager: fix trac issue #9722.Andreas Voellmy2015-03-091-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Whenever the RTS has been inactive for idleGCDelayTime, the idle timer fires and calls wakeUpRts(), which in turn calls ioManagerWakeup(), which in turn writes a byte (or a few) to a file descriptor (stored in the io_manager_wakeup_fd variable) registered by the TimerManager and on which the TimerManager will wait. (Note that the write will only occur if the file descriptor is non-negative.) When the RTS shuts down, it shuts down the TimerManager, and in this process the file descriptor stored in io_manager_wakeup_fd is closed. In the error case, the idle timer fires after the close of the file occurs, and then the write() call in ioManagerWakeup() fails and the aforementioned error message gets printed. This patch solves the problem by (1) having the TimerManager (via Control) write -1 to io_manager_wakeup_fd just before closing the file descriptor written in io_manager_wakeup_fd, and (2) having ioManagerWakeup() ignore an error returned by write() in the case that the write returned -1 and the io_manager_wakeup_fd is -1. Reviewers: austin, simonmar, hvr, thomie Reviewed By: thomie Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D722 GHC Trac Issues: #9722
* Fix #10017Andreas Voellmy2015-02-021-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | Summary: In the threaded RTS, a signal is delivered from the RTS to Haskell user code by writing to file that one of the IO managers watches (via an instance of GHC.Event.Control.Control). When the IO manager receives the signal, it calls GHC.Conc.Signal.runHandlers to invoke Haskell signal handler. In the move from a single IO manager to one IO manager per capability, the behavior was (wrongly) extended so that a signal is delivered to every event manager (see #9423), each of which invoke Haskell signal handlers, leading to multiple invocations of Haskell signal handlers for a single signal. This change fixes this problem by having the RTS (in generic_handler()) notify only the Control instance used by the TimerManager, rather than all the per-capability IO managers. Reviewers: austin, hvr, simonmar, Mikolaj Reviewed By: simonmar, Mikolaj Subscribers: thomie Differential Revision: https://phabricator.haskell.org/D641
* compiler: fix trac issue #9817Marios Titas2014-12-101-1/+1
| | | | | | | | | | | | | | | | | | | Summary: When we call runHandlers, we must pass it a ForeignPtr. To ensure that this happens, we introduce a wrapper that receives a plain Ptr and converts it into a ForeignPtr. Then we adjust startSignalHandlers in rts/posix/Signals.c to call the wrapper instead of calling runHandlers directly. Reviewers: hvr, austin, rwbarton, simonmar Reviewed By: austin, simonmar Subscribers: simonmar, thomie, carter Differential Revision: https://phabricator.haskell.org/D515 GHC Trac Issues: #9817
* Revert "Rename _closure to _static_closure, apply naming consistently."Edward Z. Yang2014-10-201-2/+2
| | | | | | | This reverts commit 35672072b4091d6f0031417bc160c568f22d0469. Conflicts: compiler/main/DriverPipeline.hs
* Rename _closure to _static_closure, apply naming consistently.Edward Z. Yang2014-10-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: In preparation for indirecting all references to closures, we rename _closure to _static_closure to ensure any old code will get an undefined symbol error. In order to reference a closure foobar_closure (which is now undefined), you should instead use STATIC_CLOSURE(foobar). For convenience, a number of these old identifiers are macro'd. Across C-- and C (Windows and otherwise), there were differing conventions on whether or not foobar_closure or &foobar_closure was the address of the closure. Now, all foobar_closure references are addresses, and no & is necessary. CHARLIKE/INTLIKE were not changed, simply alpha-renamed. Part of remove HEAP_ALLOCED patch set (#8199) Depends on D265 Signed-off-by: Edward Z. Yang <ezyang@mit.edu> Test Plan: validate Reviewers: simonmar, austin Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D267 GHC Trac Issues: #8199
* Revert "rts: add Emacs 'Local Variables' to every .c file"Simon Marlow2014-09-291-8/+0
| | | | This reverts commit 39b5c1cbd8950755de400933cecca7b8deb4ffcd.
* Revert "Revert "rts/base: Fix #9423"" and resolve issue that caused the revert.Andreas Voellmy2014-09-161-30/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This reverts commit 4748f5936fe72d96edfa17b153dbfd84f2c4c053. The fix for #9423 was reverted because this commit introduced a C function setIOManagerControlFd() (defined in Schedule.c) defined for all OS types, while the prototype (in includes/rts/IOManager.h) was only included when mingw32_HOST_OS is not defined. This broke Windows builds. This commit reverts the original commit and resolves the problem by only defining setIOManagerControlFd() when mingw32_HOST_OS is defined. Hence the missing prototype error should not occur on Windows. In addition, since the io_manager_control_wr_fd field of the Capability struct is only usd by the setIOManagerControlFd, this commit includes the io_manager_control_wr_fd field in the Capability struct only when mingw32_HOST_OS is not defined. Test Plan: Try to compile successfully on all platforms. Reviewers: austin Reviewed By: austin Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D174
* Revert "rts/base: Fix #9423"Austin Seipp2014-08-221-50/+30
| | | | | | | | | This should fix the Windows fallout, and hopefully this will be fixed once that's sorted out. This reverts commit f9f89b7884ccc8ee5047cf4fffdf2b36df6832df. Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts/base: Fix #9423Andreas Voellmy2014-08-191-30/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix #9423. The problem in #9423 is caused when code invoked by `hs_exit()` waits on all foreign calls to return, but some IO managers are in `safe` foreign calls and do not return. The previous design signaled to the timer manager (via its control pipe) that it should "die" and when the timer manager returned to Haskell-land, the Haskell code in timer manager then signalled to the IO manager threads that they should return from foreign calls and `die`. Unfortunately, in the shutdown sequence the timer manager is unable to return to Haskell-land fast enough and so the code that signals to the IO manager threads (via their control pipes) is never executed and the IO manager threads remain out in the foreign calls. This patch solves this problem by having the RTS signal to all the IO manager threads (via their control pipes; and in addition to signalling to the timer manager thread) that they should shutdown (in `ioManagerDie()` in `rts/Signals.c`. To do this, we arrange for each IO manager thread to register its control pipe with the RTS (in `GHC.Thread.startIOManagerThread`). In addition, `GHC.Thread.startTimerManagerThread` registers its control pipe. These are registered via C functions `setTimerManagerControlFd` (in `rts/Signals.c`) and `setIOManagerControlFd` (in `rts/Capability.c`). The IO manager control pipe file descriptors are stored in a new field of the `Capability_ struct`. Test Plan: See the notes on #9423 to recreate the problem and to verify that it no longer occurs with the fix. Auditors: simonmar Reviewers: simonmar, edsko, ezyang, austin Reviewed By: austin Subscribers: phaskell, simonmar, ezyang, carter, relrod Differential Revision: https://phabricator.haskell.org/D129 GHC Trac Issues: #9423, #9284
* rts: add Emacs 'Local Variables' to every .c fileAustin Seipp2014-07-281-0/+8
| | | | | | | | This will hopefully help ensure some basic consistency in the forward by overriding buffer variables. In particular, it sets the wrap length, the offset to 4, and turns off tabs. Signed-off-by: Austin Seipp <austin@well-typed.com>
* rts: delint/detab/dewhitespace Signals.cAustin Seipp2014-07-281-62/+67
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Check return value of sigactionNicolas Trangez2014-04-271-1/+3
| | | | | | Issue discovered by Coverity scan, CID 43142. Signed-off-by: Austin Seipp <austin@well-typed.com>
* In the SIGTSTP handler, throw SIGSTOP instead of re-throwing SIGTSTPSimon Marlow2012-01-031-14/+14
|
* Add a mutex around stg_sig_installSimon Marlow2011-12-121-19/+42
| | | | | | Protects against a race when two threads call installHandler simultaneously. This was causing occasional failure of the test libraries/process/tests/3231(threaded2).
* remove duplicate getStablePtr (already done in hs_init())Simon Marlow2011-12-121-4/+0
|
* change a contextSwitchCapability() to interruptCapability()Simon Marlow2011-12-121-1/+1
|
* Make forkProcess work with +RTS -NSimon Marlow2011-12-061-5/+4
| | | | | | | | | | | | | | | | | | | | | | Consider this experimental for the time being. There are a lot of things that could go wrong, but I've verified that at least it works on the test cases we have. I also did some API cleanups while I was here. Previously we had: Capability * rts_eval (Capability *cap, HaskellObj p, /*out*/HaskellObj *ret); but this API is particularly error-prone: if you forget to discard the Capability * you passed in and use the return value instead, then you're in for subtle bugs with +RTS -N later on. So I changed all these functions to this form: void rts_eval (/* inout */ Capability **cap, /* in */ HaskellObj p, /* out */ HaskellObj *ret) It's much harder to use this version incorrectly, because you have to pass the Capability in by reference.
* SafeHaskell: Fix compilation errors.David Terei2011-06-171-1/+1
|
* SafeHaskell: Even more fixing to work with safe baseDavid Terei2011-06-171-1/+1
|
* Rename System.Event to GHC.EventIan Lynagh2011-03-211-2/+2
| | | | It's just an internal GHC library, for now at least
* catch SIGTSTP and save/restore terminal settings (#4460)Simon Marlow2011-01-071-0/+77
| | | | | | | | | As far as I can tell, it is the responsibility of the program to save and restore its own terminal settings across a suspend/foreground, the shell doesn't do it (which seems odd). So I've added a signal handler for SIGTSTP to the RTS which will save and restore the terminal settings iff we modified them with hSetBuffering or hSetEcho (we already restore them at exit time in these cases).
* Use an empty signal handler for SIGPIPE instead of SIG_IGNSimon Marlow2010-09-251-1/+12
| | | | | This is so that the SIGPIPE handler gets reset to the default automatically on exec().
* Integrate new I/O manager, with signal supportJohan Tibell2010-07-241-27/+34
|
* Fix signal segfaults on Solaris (#3790)Simon Marlow2010-01-261-1/+8
|
* The rest of the #1185 patch (forkProcess and -threaded)Simon Marlow2009-11-131-1/+7
| | | | | Due to darcs confusion, I managed to leave out part of the patch for #1185. This should make 1185(threaded1) go through now.
* Second attempt to fix #1185 (forkProcess and -threaded)Simon Marlow2009-11-111-4/+15
| | | | | | | | | | | | Patch 1/2: second part of the patch is to libraries/base This time without dynamic linker hacks, instead I've expanded the existing rts/Globals.c to cache more CAFs, specifically those in GHC.Conc. We were already using this trick for signal handlers, I should have realised before. It's still quite unsavoury, but we can do away with rts/Globals.c in the future when we switch to a dynamically-linked GHCi.
* Rollback #1185 fixSimon Marlow2009-11-061-7/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As far as I can tell, the hack I was using in rts/Linker.c won't work on OS X. Back to the drawing board. rolling back: Tue Nov 3 16:05:47 GMT 2009 Simon Marlow <marlowsd@gmail.com> * Fix #1185 (RTS part, also needs corresponding change to libraries/base) GHC.Conc.ensureIOManagerIsRunning now creates an IO manager thread if one does not exist or has died/exited. Unfortunately this exposed a problem caused by the fact that we have two base packages, and hence two IO managers, in GHCi: see NOTE [io-manager-ghci] in rts/Linker.c. The workaround can go away if/when we switch to a dynamically linked GHCi. M ./rts/Linker.c -6 +47 M ./rts/Schedule.c +4 M ./rts/package.conf.in +16 M ./rts/posix/Signals.c -1 +7 M ./rts/posix/Signals.h +2 Wed Nov 4 10:11:03 GMT 2009 Simon Marlow <marlowsd@gmail.com> * hopefully fix validate breakage on OS X and Windows M ./rts/Linker.c -1 +1 Wed Nov 4 16:27:40 GMT 2009 Simon Marlow <marlowsd@gmail.com> * fix build failure on Windows M ./rts/Linker.c -1 +1
* Fix #1185 (RTS part, also needs corresponding change to libraries/base)Simon Marlow2009-11-031-1/+7
| | | | | | | | | | | GHC.Conc.ensureIOManagerIsRunning now creates an IO manager thread if one does not exist or has died/exited. Unfortunately this exposed a problem caused by the fact that we have two base packages, and hence two IO managers, in GHCi: see NOTE [io-manager-ghci] in rts/Linker.c. The workaround can go away if/when we switch to a dynamically linked GHCi.
* RTS tidyup sweep, first phaseSimon Marlow2009-08-021-7/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first phase of this tidyup is focussed on the header files, and in particular making sure we are exposinng publicly exactly what we need to, and no more. - Rts.h now includes everything that the RTS exposes publicly, rather than a random subset of it. - Most of the public header files have moved into subdirectories, and many of them have been renamed. But clients should not need to include any of the other headers directly, just #include the main public headers: Rts.h, HsFFI.h, RtsAPI.h. - All the headers needed for via-C compilation have moved into the stg subdirectory, which is self-contained. Most of the headers for the rest of the RTS APIs have moved into the rts subdirectory. - I left MachDeps.h where it is, because it is so widely used in Haskell code. - I left a deprecated stub for RtsFlags.h in place. The flag structures are now exposed by Rts.h. - Various internal APIs are no longer exposed by public header files. - Various bits of dead code and declarations have been removed - More gcc warnings are turned on, and the RTS code is more warning-clean. - More source files #include "PosixSource.h", and hence only use standard POSIX (1003.1c-1995) interfaces. There is a lot more tidying up still to do, this is just the first pass. I also intend to standardise the names for external RTS APIs (e.g use the rts_ prefix consistently), and declare the internal APIs as hidden for shared libraries.