diff options
| author | ruki <[email protected]> | 2024-03-31 22:17:29 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-31 22:17:29 +0800 |
| commit | 1f2ca3502f9b01da53d76d517f0e2706a8b32364 (patch) | |
| tree | 5937f2b57746ef2e1aa59474193b34d7ce27c2c7 /xmake/core/base | |
| parent | dee0d869c5630bbbf464be28ca62331be36aff3d (diff) | |
| parent | 454048ab2a488f706801c4cc15a06272a8b005a8 (diff) | |
Merge pull request #4908 from xmake-io/signal
Add signal module
Diffstat (limited to 'xmake/core/base')
| -rw-r--r-- | xmake/core/base/os.lua | 9 | ||||
| -rw-r--r-- | xmake/core/base/signal.lua | 46 |
2 files changed, 46 insertions, 9 deletions
diff --git a/xmake/core/base/os.lua b/xmake/core/base/os.lua index 836a8991f..2d7023ac4 100644 --- a/xmake/core/base/os.lua +++ b/xmake/core/base/os.lua @@ -45,7 +45,6 @@ os._getenvs = os._getenvs or os.getenvs os._cpuinfo = os._cpuinfo or os.cpuinfo os._meminfo = os._meminfo or os.meminfo os._readlink = os._readlink or os.readlink -os._signal = os._signal or os.signal -- syserror code os.SYSERR_UNKNOWN = -1 @@ -54,9 +53,6 @@ os.SYSERR_NOT_PERM = 1 os.SYSERR_NOT_FILEDIR = 2 os.SYSERR_NOT_ACCESS = 3 --- signal code -os.SIGINT = 1 - -- copy single file or directory function os._cp(src, dst, rootdir, opt) opt = opt or {} @@ -1419,11 +1415,6 @@ function os.readlink(symlink) return os._readlink(path.absolute(symlink)) end --- register signal handler -function os.signal(signo, handler) - os._signal(signo, handler) -end - -- get the program directory function os.programdir() return xmake._PROGRAM_DIR diff --git a/xmake/core/base/signal.lua b/xmake/core/base/signal.lua new file mode 100644 index 000000000..e281bb1f4 --- /dev/null +++ b/xmake/core/base/signal.lua @@ -0,0 +1,46 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file signal.lua +-- + +-- define module: signal +local signal = signal or {} + +-- load modules +local os = require("base/os") + +-- signal code +signal.SIGINT = 2 + +-- register signal handler +function signal.register(signo, handler) + os.signal(signo, handler) +end + +-- reset signal, SIGDFL +function signal.reset(signo) + os.signal(signo, 1) +end + +-- ignore signal, SIGIGN +function signal.ignore(signo) + os.signal(signo, 2) +end + +-- return module: signal +return signal |
