changed system-calls to avoid namespace pollution
This commit is contained in:
parent
a816b64b86
commit
0ab62357ce
|
@ -6,13 +6,13 @@
|
||||||
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
int kill(int pid, int sig);
|
int _kill(int pid, int sig);
|
||||||
int getpid(void);
|
int _getpid(void);
|
||||||
|
|
||||||
int
|
int
|
||||||
raise(int sig)
|
raise(int sig)
|
||||||
{
|
{
|
||||||
if (sig < 0 || sig > _NSIG)
|
if (sig < 0 || sig > _NSIG)
|
||||||
return -1;
|
return -1;
|
||||||
return kill(getpid(), sig);
|
return _kill(_getpid(), sig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,9 +7,12 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
extern void (*_clean)(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
abort(void)
|
abort(void)
|
||||||
{
|
{
|
||||||
|
if (_clean) _clean(); /* flush all output files */
|
||||||
raise(SIGABRT);
|
raise(SIGABRT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,8 +13,9 @@ void (*__functab[NEXITS])(void);
|
||||||
int __funccnt = 0;
|
int __funccnt = 0;
|
||||||
|
|
||||||
extern void _exit(int);
|
extern void _exit(int);
|
||||||
/* only fflush when there is output */
|
|
||||||
int (*_fflush)(FILE *stream) = NULL;
|
/* only flush output buffers when necessary */
|
||||||
|
int (*_clean)(void) = NULL;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_calls(void)
|
_calls(void)
|
||||||
|
@ -30,6 +31,6 @@ void
|
||||||
exit(int status)
|
exit(int status)
|
||||||
{
|
{
|
||||||
_calls();
|
_calls();
|
||||||
if (_fflush) _fflush((FILE *)NULL) ;
|
if (_clean) _clean();
|
||||||
_exit(status) ;
|
_exit(status) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
extern int fork(void);
|
extern int _fork(void);
|
||||||
extern int wait(int *);
|
extern int _wait(int *);
|
||||||
extern void _exit(int);
|
extern void _exit(int);
|
||||||
extern void execl(char *, ...);
|
extern void _execl(char *, ...);
|
||||||
extern void close(int);
|
extern void _close(int);
|
||||||
|
|
||||||
#define FAIL 127
|
#define FAIL 127
|
||||||
|
|
||||||
|
@ -21,17 +21,17 @@ system(const char *str)
|
||||||
int pid, exitstatus, waitval;
|
int pid, exitstatus, waitval;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if ((pid = fork()) < 0) return str ? -1 : 0;
|
if ((pid = _fork()) < 0) return str ? -1 : 0;
|
||||||
|
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
for (i = 3; i <= 20; i++)
|
for (i = 3; i <= 20; i++)
|
||||||
close(i);
|
_close(i);
|
||||||
if (!str) str = "cd ."; /* just testing for a shell */
|
if (!str) str = "cd ."; /* just testing for a shell */
|
||||||
execl("/bin/sh", "sh", "-c", str, (char *) NULL);
|
_execl("/bin/sh", "sh", "-c", str, (char *) NULL);
|
||||||
/* get here if execl fails ... */
|
/* get here if execl fails ... */
|
||||||
_exit(FAIL); /* see manual page */
|
_exit(FAIL); /* see manual page */
|
||||||
}
|
}
|
||||||
while ((waitval = wait(&exitstatus)) != pid) {
|
while ((waitval = _wait(&exitstatus)) != pid) {
|
||||||
if (waitval == -1) break;
|
if (waitval == -1) break;
|
||||||
}
|
}
|
||||||
if (waitval == -1) {
|
if (waitval == -1) {
|
||||||
|
|
Loading…
Reference in a new issue