Compare commits

..

2 Commits

Author SHA1 Message Date
f7f4ead790 updated README.md and the rpm spec file
All checks were successful
continuous-integration/drone/push Build is passing
2026-01-14 14:06:40 +09:00
0c5cf2edc1 more documetnation on singal handling
All checks were successful
continuous-integration/drone/push Build is passing
2026-01-13 18:24:13 +09:00
2 changed files with 69 additions and 7 deletions

View File

@@ -182,6 +182,44 @@ $ gcc -Wall -O2 -o hawk02 hawk02.c -lhawk
The actual command may vary depending on the compiler used and the `configure` options used.
## Embedding Signal Handling
Signal handling is provided via a callback hook. The core library does not install OS-level signal handlers; the embedding application must do that and notify the runtime.
- Register a runtime callback with `hawk_rtx_pushecb()` and fill `hawk_rtx_ecb_t.sigset` (type `hawk_rtx_ecb_sigset_t`).
- Your callback is invoked when `sys::signal()` sets or clears a handler; use it to install or reset the OS signal handler.
- When the OS handler runs, call `hawk_rtx_raisesig()` on the target runtime.
Example:
```c
static hawk_rtx_t* g_rtx = HAWK_NULL;
static void on_os_signal (int sig)
{
if (g_rtx) hawk_rtx_raisesig(g_rtx, sig);
}
static void on_sigset (hawk_rtx_t* rtx, int sig, hawk_fun_t* fun)
{
if (fun)
{
g_rtx = rtx;
signal(sig, on_os_signal);
}
else
{
if (g_rtx == rtx) g_rtx = HAWK_NULL;
signal(sig, SIG_DFL);
}
}
hawk_rtx_ecb_t ecb;
memset(&ecb, 0, HAWK_SIZEOF(ecb));
ecb.sigset = on_sigset;
hawk_rtx_pushecb(rtx, &ecb);
```
# Embedding Hawk in C++ Applications
Hawk can also be embedded in C++ applications. Here's an example:
@@ -1002,9 +1040,11 @@ The `sys` module provides various functions concerning the underlying operation
- sys::opendir
- sys::openfd
- sys::pipe
- sys::raise
- sys::read
- sys::readdir
- sys::setttime
- sys::signal
- sys::sleep
- sys::strftime
- sys::system

View File

@@ -5,11 +5,11 @@
%define __brp_remove_la_files /bin/true
%define source_date_epoch_from_changelog 0
%define enable_mod_ffi 1
%define enable_mod_memc 0
%define enable_mod_mysql 1
%define enable_mod_sqlite 1
%define enable_mod_uci 0
%{!?enable_mod_ffi:%define enable_mod_ffi 1}
%{!?enable_mod_memc:%define enable_mod_memc 0}
%{!?enable_mod_mysql:%define enable_mod_mysql 1}
%{!?enable_mod_sqlite:%define enable_mod_sqlite 1}
%{!?enable_mod_uci:%define enable_mod_uci 0}
Summary: Hawk Interpreter
Name: @PACKAGE_NAME@
@@ -26,20 +26,31 @@ Requires: %{name}-libs%{?_isa}
## prep_cif_var() available since 3.0.11
BuildRequires: libffi-devel%{?_isa} >= 3.0.11
%endif
%if %{enable_mod_memc}
BuildRequires: libmemcached-devel%{?_isa} >= 1.0.18
%endif
%if %{enable_mod_mysql}
##BuildRequires: mariadb-connector-c-devel%{?_isa}
%if 0%{?fedora} > 22
BuildRequires: mariadb-connector-c-devel%{?_isa}
%else
%if 0%{?suse_version} > 0
BuildRequires: libmariadb-devel%{?_isa}
%else
BuildRequires: mysql-devel%{?_isa}
%endif
%endif
%endif
%if %{enable_mod_sqlite}
BuildRequires: sqlite-devel%{?_isa}
%endif
%if %{enable_mod_uci}
BuildRequires: libuci-devel%{?_isa}
%endif
@@ -83,8 +94,19 @@ This package contains the memc module file for Hawk.
Summary: Hawk mysql module
Group: System Environment/Libraries
Requires: %{name}-libs%{?_isa} = %{version}
%if 0%{?fedora} > 22
Requires: mariadb-connector-c%{?_isa}
%else
%if 0%{?suse_version} > 0
Requires: libmariadb%{?_isa}
%else
## tricky to specify the right mysql/mariadb client library.
##Requires: mariadb-connector-c%{?_isa}
Requires:
%endif
%endif
%description mysql
This package contains the mysql module file for Hawk.