theKernel 10.0 NHI1 - theKernel - theLink - theConfig - theSq3Lite - theCompiler - theBrain - theGuard
c - tcl - cs - py - rb - jv - cc
Loading...
Searching...
No Matches
MkLalS Struct Reference

Interface between libmkkernel and the Operating-System … More...

#include <LibMkKernel_mk.h>

+ Collaboration diagram for MkLalS:

Data Fields

MkSysCallocF SysCalloc
 calloc syscall …
 
MkSysMallocF SysMalloc
 malloc syscall …
 
MkSysReallocF SysRealloc
 realloc syscall …
 
MkSysStrNDupF SysStrNDup
 strndup syscall …
 
MkSysStrDupF SysStrDup
 strdup syscall …
 
MkSysStrNCpyF SysStrNCpy
 strdup strncpy …
 
MkSysFreeF SysFree
 free syscall …
 
MkSysForkF SysFork
 fork syscall …
 
MK_PTR SysForkData
 
MkSysWaitF MkSysWaitForProcessCB
 wait for process to finish syscall with libmkkernel error plugin
 
MkSysWaitF MkSysWaitForThreadCB
 wait for process to finish syscall with libmkkernel error plugin
 
enum MkErrorE(* SysUSleep )(MK_OBJN const obj, unsigned int const usec)
 usleep syscall with libmkkernel error plugin
 
enum MkErrorE(* SysSleep )(MK_OBJN const obj, unsigned int const sec)
 sleep syscall with libmkkernel error plugin
 
enum MkErrorE(* SysDaemonize )(MK_RT mkrt, MK_OBJN const obj, MK_STRN pidfile)
 demonize the current process and save the resulting PID into the pidfile
 
MkSysExitF MkSysExitCB
 exit syscall with libmkkernel error plugin
 
void(* SysAbort )(void)
 abort syscall …
 
enum MkErrorE(* SysIgnorSIGCHLD )(MK_RT mkrt, MK_OBJ const obj)
 
enum MkErrorE(* SysAllowSIGCHLD )(MK_RT mkrt, MK_OBJ const obj)
 

Detailed Description

Interface between libmkkernel and the Operating-System …

Definition at line 2469 of file LibMkKernel_mk.h.

Field Documentation

◆ MkSysExitCB

MkSysExitF MkLalS::MkSysExitCB

exit syscall with libmkkernel error plugin

Parameters
[in]mkrtthe MkRuntimeS instance to work on - the runtime argument, used by MK_RT_CALL (C-only)
[in]isThreadexit a thread?
[in]numexit code
Attention
No MK_NO_RETURN besause the MkSysExit can be an overload with MkLalS::MkSysExitCB

Example:

MK_NO_RETURN static void SysExit (
int isThread,
int num
) {
if (isThread) {
#if META_HAS_THREAD
# if defined(HAVE_PTHREAD)
/*
int state;
pthread_attr_t attr;
pthread_getattr_np(pthread_self(), &attr);
pthread_attr_getdetachstate(&attr, &state);
if (state == PTHREAD_CREATE_DETACHED)
pthread_detach(pthread_self());
*/
// BUG-FIX-pthread_detach
// "pthread_detach" disable "pthread_join" an create a "random-crash" in "MkSysWait" called by "pIoDelete"
pthread_exit(NULL);
# elif defined(META_IS_WINDOWS)
_endthreadex(num);
# endif
#endif /* META_HAS_THREAD */
#if 1
}
exit(num);
#define MK_NO_RETURN
dosable "MK_NO_RETURN" because C# require "return" from "MqExit" for thread-pool support
#define MK_RT_ARGS
#else
} else {
Attention
no MK_NO_RETURN besause the MkSysExitF can be an overload with MkLalS::MkSysExitCB

Definition at line 2534 of file LibMkKernel_mk.h.

◆ MkSysWaitForProcessCB

MkSysWaitF MkLalS::MkSysWaitForProcessCB

wait for process to finish syscall with libmkkernel error plugin

Parameters
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]idprocess handle
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk
See also
MkSysWaitForProcess, MkSysWaitForThread

Definition at line 2488 of file LibMkKernel_mk.h.

◆ MkSysWaitForThreadCB

MkSysWaitF MkLalS::MkSysWaitForThreadCB

wait for process to finish syscall with libmkkernel error plugin

Parameters
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]idprocess handle
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk
See also
MkSysWaitForProcess, MkSysWaitForThread

Definition at line 2490 of file LibMkKernel_mk.h.

◆ SysAbort

void(* MkLalS::SysAbort) (void)

abort syscall …

additional info: man abort

Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Example:

__attribute__((noreturn)) static void SysAbort (void) {
abort();
}
void(* SysAbort)(void)
abort syscall …

Definition at line 2544 of file LibMkKernel_mk.h.

◆ SysAllowSIGCHLD

enum MkErrorE(* MkLalS::SysAllowSIGCHLD) (MK_RT mkrt, MK_OBJ const obj)

Definition at line 2544 of file LibMkKernel_mk.h.

◆ SysCalloc

MkSysCallocF MkLalS::SysCalloc

calloc syscall …

additional info: man calloc

Definition at line 2471 of file LibMkKernel_mk.h.

◆ SysDaemonize

enum MkErrorE(* MkLalS::SysDaemonize) (MK_RT mkrt, MK_OBJN const obj, MK_STRN pidfile)

demonize the current process and save the resulting PID into the pidfile

Parameters
[in]obj...
[in]pidfilefile to save the process identifier, can be used to kill the process later
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Example:

static enum MkErrorE SysDaemonize (
MK_OBJN const errobj,
MK_STRN pidfile
) {
#if defined(META_IS_POSIX) && !defined(__CYGWIN__)
int fd, fpid;
struct MkIdS id;
// step 0 -> open the pidfile
if ((fpid = open(pidfile, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH)) == -1)
return MkErrorSysOS (open);
// step 1 -> delete initial process
MkErrorCheck(pMkSysFork(MK_RT_CALL errobj, &id));
if (id.val != 0UL)
_exit(0);
// step 2 -> create a new session
if (setsid() == -1)
return MkErrorSysOS (setsid);
// step 3 -> fork the new process, parent write the pid
MkErrorCheck(pMkSysFork(MK_RT_CALL errobj, &id));
if (id.val != 0UL) {
char buf[40];
int num = snprintf(buf, 40, "%lu", (long unsigned)id.val);
write(fpid,buf,(size_t)num);
_exit(0);
}
// step 4 -> close the fpid after writing
if (close(fpid) == -1)
return MkErrorSys (close);
// step 5 -> close default io
fd = open("/dev/null", O_RDONLY);
if (fd != 0) {
dup2(fd, 0);
close(fd);
}
fd = open("/dev/null", O_WRONLY);
if (fd != 1) {
dup2(fd, 1);
close(fd);
}
fd = open("/dev/null", O_WRONLY);
if (fd != 2) {
dup2(fd, 2);
close(fd);
}
return MK_OK;
error:
return MkErrorStack_1M(errobj);
#else
return MkErrorDbV_1_OS(MK_ERROR_NOT_SUPPORTED, "SysDaemonize");
#define MkErrorCheck(err)
check return-code and goto error on error …
#define MkErrorStack_1M(err)
MkErrorE
collection for the different error-codes …
@ MK_OK
(persistent) everything is OK.
const MK_STRB * MK_STRN
constant string pointer data-type
#define MK_RT_CALL
data type for process/thread identification …
enum MkErrorE(* SysDaemonize)(MK_RT mkrt, MK_OBJN const obj, MK_STRN pidfile)
demonize the current process and save the resulting PID into the pidfile …
object header …
#endif
}

Definition at line 2490 of file LibMkKernel_mk.h.

◆ SysFork

MkSysForkF MkLalS::SysFork

fork syscall …

additional info: man fork

Returns
the process identifier of the new child (in the parent process) or 0 (in the child process)

Definition at line 2485 of file LibMkKernel_mk.h.

◆ SysForkData

MK_PTR MkLalS::SysForkData

Definition at line 2486 of file LibMkKernel_mk.h.

◆ SysFree

MkSysFreeF MkLalS::SysFree

free syscall …

additional info: man free

Definition at line 2483 of file LibMkKernel_mk.h.

◆ SysIgnorSIGCHLD

enum MkErrorE(* MkLalS::SysIgnorSIGCHLD) (MK_RT mkrt, MK_OBJ const obj)

Definition at line 2544 of file LibMkKernel_mk.h.

◆ SysMalloc

MkSysMallocF MkLalS::SysMalloc

malloc syscall …

additional info: man malloc

Definition at line 2473 of file LibMkKernel_mk.h.

◆ SysRealloc

MkSysReallocF MkLalS::SysRealloc

realloc syscall …

additional info: man realloc

Definition at line 2475 of file LibMkKernel_mk.h.

◆ SysSleep

enum MkErrorE(* MkLalS::SysSleep) (MK_OBJN const obj, unsigned int const sec)

sleep syscall with libmkkernel error plugin

Parameters
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]secthe seconds to sleep
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Example:

static enum MkErrorE SysSleep (
MK_OBJN const errobj,
unsigned int const sec
) {
#if defined(META_IS_POSIX)
if (sleep (sec) != 0) {
return MkErrorSys (sleep);
}
enum MkErrorE(* SysSleep)(MK_OBJN const obj, unsigned int const sec)
sleep syscall with libmkkernel error plugin
#elif defined (META_IS_WINDOWS)
Sleep (sec * 1000);
#else
# error not supported
#endif
return MK_OK;
}

Definition at line 2490 of file LibMkKernel_mk.h.

◆ SysStrDup

MkSysStrDupF MkLalS::SysStrDup

strdup syscall …

additional info: man strdup

Definition at line 2479 of file LibMkKernel_mk.h.

◆ SysStrNCpy

MkSysStrNCpyF MkLalS::SysStrNCpy

strdup strncpy …

additional info: man strncpy

Definition at line 2481 of file LibMkKernel_mk.h.

◆ SysStrNDup

MkSysStrNDupF MkLalS::SysStrNDup

strndup syscall …

additional info: man strndup

Definition at line 2477 of file LibMkKernel_mk.h.

◆ SysUSleep

enum MkErrorE(* MkLalS::SysUSleep) (MK_OBJN const obj, unsigned int const usec)

usleep syscall with libmkkernel error plugin

Parameters
[in]fmtobjmanaged object used to format the log-message (default=MK_NULL → use default-format)
[in]usecthe micro (10^-6) seconds to sleep
Returns
The MkErrorE status from the DEFAULT MkErrorC in MkRuntimeS::error_mk

Example:

static enum MkErrorE SysUSleep (
MK_OBJN const errobj,
unsigned int const usec
) {
#if defined(META_IS_POSIX)
usleep (usec);
#elif defined (META_IS_WINDOWS)
Sleep ((usec + 500) / 1000);
#else
# error not supported
#endif
return MK_OK;
}
enum MkErrorE(* SysUSleep)(MK_OBJN const obj, unsigned int const usec)
usleep syscall with libmkkernel error plugin
static enum MkErrorE SysSleep (
MK_OBJN const errobj,
unsigned int const sec
) {
#if defined(META_IS_POSIX)
if (sleep (sec) != 0) {
return MkErrorSys (sleep);
}

Definition at line 2490 of file LibMkKernel_mk.h.


The documentation for this struct was generated from the following file: