libposix: build again

This commit is contained in:
Giacomo Tesio 2017-05-25 22:42:20 +02:00
parent a59b992ed4
commit abfc6958d6
4 changed files with 30 additions and 28 deletions

View File

@ -15,6 +15,9 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with Jehanne. If not, see <http://www.gnu.org/licenses/>. * along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
*/ */
#define __POSIX_SIGNAL_PREFIX_LEN (sizeof(__POSIX_SIGNAL_PREFIX)-1)
typedef struct WaitList WaitList; typedef struct WaitList WaitList;
struct WaitList struct WaitList
{ {
@ -53,3 +56,9 @@ extern int __libposix_note_to_signal(char *note);
extern int __libposix_is_child(int pid); extern int __libposix_is_child(int pid);
extern void __libposix_forget_child(int pid); extern void __libposix_forget_child(int pid);
extern int __libposix_send_control_msg(int pid, char *msg);
extern PosixError __libposix_notify_signal_to_process(int pid, int signal);
extern PosixError __libposix_receive_signal(int sig);

View File

@ -102,7 +102,7 @@ __libposix_forget_child(int pid)
/* free the wait list as the memory is shared */ /* free the wait list as the memory is shared */
l = __libposix_child_list; l = __libposix_child_list;
while(*l != nil){ while(*l != nil){
c = *l c = *l;
if(c->pid == pid){ if(c->pid == pid){
*l = c->next; *l = c->next;
free(c); free(c);

View File

@ -44,19 +44,20 @@ release_inherited_resources(void)
static void static void
forwarding_note_handler(void *ureg, char *note) forwarding_note_handler(void *ureg, char *note)
{ {
extern int __min_known_sig;
extern int __max_known_sig;
int sig; int sig;
PosixSignals psig; PosixSignals signal;
if(strncmp(note, __POSIX_SIGNAL_PREFIX, __POSIX_SIGNAL_PREFIX_LEN) == 0){ if(strncmp(note, __POSIX_SIGNAL_PREFIX, __POSIX_SIGNAL_PREFIX_LEN) == 0){
sig = __libposix_note_to_signal(note); sig = __libposix_note_to_signal(note);
if(sig < __min_known_sig || sig > __max_known_sig){ if(sig < __min_known_sig || sig > __max_known_sig){
/* Ignore unknown signals */ /* Ignore unknown signals */
noted(NCONT); noted(NCONT);
} }
psig = __code_to_signal_map[sig]; signal = __code_to_signal_map[sig];
switch(psig){ __libposix_notify_signal_to_process(*__libposix_sigchld_target_pid, sig);
if(signal == PosixSIGCONT)
} __libposix_send_control_msg(*__libposix_sigchld_target_pid, "start");
postnote(PNPROC, *__libposix_sigchld_target_pid, note);
noted(NCONT); noted(NCONT);
} else { } else {
/* what happened? */ /* what happened? */

View File

@ -121,16 +121,14 @@
#include <posix.h> #include <posix.h>
#include "internal.h" #include "internal.h"
#define __POSIX_SIGNAL_PREFIX_LEN (sizeof(__POSIX_SIGNAL_PREFIX)-1)
unsigned char *__signals_to_code_map; unsigned char *__signals_to_code_map;
unsigned char *__code_to_signal_map; unsigned char *__code_to_signal_map;
int *__handling_external_signal; int *__handling_external_signal;
static int __sigrtmin; static int __sigrtmin;
static int __sigrtmax; static int __sigrtmax;
static int __min_known_sig; int __min_known_sig;
static int __max_known_sig; int __max_known_sig;
static PosixSignalTrampoline __libposix_signal_trampoline; static PosixSignalTrampoline __libposix_signal_trampoline;
typedef enum PosixSignalDisposition typedef enum PosixSignalDisposition
@ -142,12 +140,11 @@ typedef enum PosixSignalDisposition
ResumeTheProcess ResumeTheProcess
} PosixSignalDisposition; } PosixSignalDisposition;
static int static PosixError
note_all_writable_processes(int *errnop, int sig) note_all_writable_processes(int sig)
{ {
// TODO: loop over writable note files and post note. // TODO: loop over writable note files and post note.
*errnop = __libposix_get_errno(PosixEPERM); return PosixEPERM;
return -1;
} }
static void static void
@ -288,8 +285,8 @@ __libposix_notify_signal_to_process(int pid, int signal)
return 0; return 0;
} }
PosixError static PosixError
__libposix_notify_signal_to_group(int pid, int signal) notify_signal_to_group(int pid, int signal)
{ {
char buf[128]; char buf[128];
int fd, n; int fd, n;
@ -314,12 +311,12 @@ dispatch_signal(int pid, int sig)
PosixError error; PosixError error;
switch(pid){ switch(pid){
case 0: case 0:
return __libposix_notify_signal_to_group(getpid(), sig); return notify_signal_to_group(getpid(), sig);
case -1: case -1:
return note_all_writable_processes(sig); return note_all_writable_processes(sig);
default: default:
if(pid < 0) if(pid < 0)
return __libposix_notify_signal_to_group(-pid, sig); return notify_signal_to_group(-pid, sig);
break; break;
} }
signal = __code_to_signal_map[sig]; signal = __code_to_signal_map[sig];
@ -333,7 +330,6 @@ int
POSIX_kill(int *errnop, int pid, int sig) POSIX_kill(int *errnop, int pid, int sig)
{ {
PosixSignals signal; PosixSignals signal;
PosixSignalDisposition action;
PosixError perror; PosixError perror;
signal = __code_to_signal_map[sig]; signal = __code_to_signal_map[sig];
@ -367,21 +363,17 @@ __libposix_note_to_signal(char *note)
int int
__libposix_note_handler(void *ureg, char *note) __libposix_note_handler(void *ureg, char *note)
{ {
int sig, ret; int sig;
PosixSignalDisposition action; PosixError error;
if(strncmp(note, __POSIX_SIGNAL_PREFIX, __POSIX_SIGNAL_PREFIX_LEN) != 0) if(strncmp(note, __POSIX_SIGNAL_PREFIX, __POSIX_SIGNAL_PREFIX_LEN) != 0)
return translate_jehanne_note(note); // TODO: should we translate common notes? return translate_jehanne_note(note); // TODO: should we translate common notes?
sig = __libposix_note_to_signal(note); sig = __libposix_note_to_signal(note);
if(sig < __min_known_sig || sig > __max_known_sig) if(sig < __min_known_sig || sig > __max_known_sig)
sysfatal("libposix: '%s' does not carry a signal", note); sysfatal("libposix: '%s' does not carry a signal", note);
*__handling_external_signal = 1; *__handling_external_signal = 1;
if(__libposix_signal_trampoline(sig)) error = __libposix_receive_signal(sig);
action = SignalHandled;
else
action = default_signal_disposition(sig);
ret = execute_disposition(sig, action, -1);
*__handling_external_signal = 0; *__handling_external_signal = 0;
return ret; return error == 0;
} }
int int