Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clean-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
13
Issues
13
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clean-and-itasks
clean-platform
Commits
033740f8
Commit
033740f8
authored
Apr 01, 2019
by
Mart Lubbers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial signal API
parent
870958dd
Pipeline
#20538
failed with stage
in 3 minutes and 6 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
103 additions
and
0 deletions
+103
-0
src/libraries/OS-Posix/System/Signal.dcl
src/libraries/OS-Posix/System/Signal.dcl
+37
-0
src/libraries/OS-Posix/System/Signal.icl
src/libraries/OS-Posix/System/Signal.icl
+31
-0
src/libraries/OS-Posix/System/systemsignal.c
src/libraries/OS-Posix/System/systemsignal.c
+34
-0
tests/linux64/test.icl
tests/linux64/test.icl
+1
-0
No files found.
src/libraries/OS-Posix/System/Signal.dcl
0 → 100644
View file @
033740f8
definition
module
System
.
Signal
from
Data
.
Error
import
::
MaybeErrorString
,
::
MaybeError
from
System
.
OSError
import
::
MaybeOSError
,
::
OSError
,
::
OSErrorMessage
,
::
OSErrorCode
::
SigHandler
//All portable signals numbers:
SIGABRT
:==
6
SIGALRM
:==
14
SIGHUP
:==
1
SIGINT
:==
2
SIGKILL
:==
9
// Can't catch that one
SIGQUIT
:==
3
SIGTERM
:==
15
SIGTRAP
:==
5
/*
* Install a signal handler
*
* @param Signal type
* @param World
* @return Error or handler
* @return New world
*/
signalInstall
::
!
Int
!*
env
->
*(
MaybeOSError
*
SigHandler
,
!*
env
)
/*
* Poll a signal, this resets the state
*
* @param Signal handler
* @param World
* @return Was thrown
* @return New handler
* @return New world
*/
signalPoll
::
!*
SigHandler
!*
env
->
*(!
MaybeErrorString
Bool
,
!*
SigHandler
,
!*
env
)
src/libraries/OS-Posix/System/Signal.icl
0 → 100644
View file @
033740f8
implementation
module
System
.
Signal
import
StdEnv
import
Data
.
Error
import
System
.
OSError
import
code
from
"systemsignal.o"
::
SigHandler
:==
Int
signalInstall
::
!
Int
!*
env
->
*(
MaybeOSError
*
SigHandler
,
!*
env
)
signalInstall
signum
w
#
(
ok
,
h
,
w
)
=
signalInstall_
signum
w
|
ok
<>
0
=
getLastOSError
w
=
(
Ok
h
,
w
)
where
signalInstall_
::
!
Int
!*
env
->
*(!
Int
,
!*
SigHandler
,
!*
env
)
signalInstall_
_
_
=
code {
ccall
signal_install
"I:VII:A"
}
signalPoll
::
!*
SigHandler
!*
env
->
*(!
MaybeErrorString
Bool
,
!*
SigHandler
,
!*
env
)
signalPoll
h
w
#
(
ok
,
s
,
h
,
w
)
=
signalPoll_
h
w
|
ok
<>
0
=
(
Error
"Invalid handler"
,
h
,
w
)
=
(
Ok
s
,
h
,
w
)
where
signalPoll_
::
!*
SigHandler
!*
env
->
*(!
Int
,
!
Bool
,
!*
SigHandler
,
!*
env
)
signalPoll_
_
_=
code {
ccall
signal_poll
"I:VIII:A"
}
src/libraries/OS-Posix/System/systemsignal.c
0 → 100644
View file @
033740f8
#include <stdlib.h>
#include <signal.h>
static
long
signal_state
[
NSIG
]
=
{
0
};
static
void
signal_handler
(
int
sig
,
siginfo_t
*
si
,
void
*
unused
)
{
signal_state
[
sig
]
=
1
;
(
void
)
si
;
(
void
)
unused
;
}
void
signal_install
(
long
signum
,
long
*
ok
,
long
*
handler
)
{
struct
sigaction
act
;
act
.
sa_flags
=
SA_SIGINFO
;
sigemptyset
(
&
act
.
sa_mask
);
act
.
sa_sigaction
=
signal_handler
;
*
ok
=
sigaction
(
signum
,
&
act
,
NULL
);
*
handler
=
signum
;
}
void
signal_poll
(
long
handler
,
long
*
ok
,
long
*
state
,
long
*
handlerr
)
{
*
ok
=
1
;
if
(
0
<
handler
&&
handler
<
NSIG
){
*
handlerr
=
handler
;
*
state
=
signal_state
[
handler
];
signal_state
[
handler
]
=
0
;
*
ok
=
0
;
}
}
tests/linux64/test.icl
View file @
033740f8
...
...
@@ -175,6 +175,7 @@ import qualified System.Process
import
qualified
System
.
TTS
import
qualified
System
.
Time
import
qualified
System
.
Time
.
GenJSON
import
qualified
System
.
Signal
import
qualified
System
.
_Directory
import
qualified
System
.
_FilePath
import
qualified
System
.
_Finalized
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment