Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
clean-and-itasks
clm
Commits
d59090a4
Commit
d59090a4
authored
May 21, 2003
by
Diederik van Arkel
Browse files
get return code and log from 'system' call;
parent
7c65f197
Changes
3
Hide whitespace changes
Inline
Side-by-side
CleanIDE/Mac/Clean System Files/cUtilSystem.o
View file @
d59090a4
No preview for this file type
CleanIDE/Mac/Clean System Files/cUtilSystem.xo
View file @
d59090a4
No preview for this file type
CleanIDE/Mac/cUtilSystem.c
View file @
d59090a4
#ifndef __MACH__
#include
<Carbon.h>
#
include <Carbon.h>
#else
#include
<Carbon/Carbon.h>
# include <Carbon/Carbon.h>
# include <fcntl.h>
#endif
CFBundleRef
systemBundle
=
NULL
;
#ifndef __MACH__
typedef
int
pid_t
;
typedef
int
mode_t
;
#define O_WRONLY 0x0001
#define O_CREAT 0x0200
#define O_TRUNC 0x0400
pid_t
(
*
fork_p
)(
void
)
=
NULL
;
int
(
*
execv_p
)(
const
char
*
path
,
char
*
const
argv
[])
=
NULL
;
pid_t
(
*
waitpid_p
)(
pid_t
wpid
,
int
*
status
,
int
options
)
=
NULL
;
int
(
*
open_p
)(
const
char
*
path
,
int
flags
,
mode_t
mode
)
=
NULL
;
int
(
*
dup2_p
)
(
int
oldd
,
int
newd
)
=
NULL
;
int
(
*
close_p
)
(
int
d
)
=
NULL
;
#endif
#ifndef __MACH__
...
...
@@ -150,9 +159,66 @@ pid_t waitpid (pid_t wpid,int *status,int options)
return
r
;
}
int
open
(
const
char
*
path
,
int
flags
,
mode_t
mode
)
{
int
r
,
t
;
if
(
open_p
==
NULL
){
if
(
systemBundle
==
NULL
)
initSystemBundle
();
open_p
=
(
int
(
*
)(
const
char
*
path
,
int
flags
,
mode_t
mode
))
CFBundleGetFunctionPointerForName
(
systemBundle
,
CFSTR
(
"open"
));
if
(
open_p
==
NULL
)
return
-
1
;
}
t
=
get_toc
();
r
=
(
*
open_p
)
(
path
,
flags
,
mode
);
set_toc
(
t
);
return
r
;
}
int
dup2
(
int
oldd
,
int
newd
)
{
int
r
,
t
;
if
(
dup2_p
==
NULL
){
if
(
systemBundle
==
NULL
)
initSystemBundle
();
dup2_p
=
(
int
(
*
)(
int
oldd
,
int
newd
))
CFBundleGetFunctionPointerForName
(
systemBundle
,
CFSTR
(
"dup2"
));
if
(
dup2_p
==
NULL
)
return
-
1
;
}
t
=
get_toc
();
r
=
(
*
dup2_p
)
(
oldd
,
newd
);
set_toc
(
t
);
return
r
;
}
int
close
(
int
d
)
{
int
r
,
t
;
if
(
close_p
==
NULL
){
if
(
systemBundle
==
NULL
)
initSystemBundle
();
close_p
=
(
int
(
*
)(
int
d
))
CFBundleGetFunctionPointerForName
(
systemBundle
,
CFSTR
(
"close"
));
if
(
close_p
==
NULL
)
return
-
1
;
}
t
=
get_toc
();
r
=
(
*
close_p
)
(
d
);
set_toc
(
t
);
return
r
;
}
#endif
int
fork_execv_waitpid
(
char
*
command
)
int
fork_execv_waitpid
(
char
*
command
,
char
*
stderr_file_name
,
int
*
status_p
)
{
char
*
p
,
*
(
argv
[
2049
]);
int
argc
,
result
;
...
...
@@ -209,14 +275,25 @@ int fork_execv_waitpid (char *command)
}
argv
[
argc
]
=
NULL
;
if
(
argc
>
0
){
int
pid
,
status
;
int
pid
;
pid
=
fork
();
if
(
pid
==
0
)
if
(
pid
==
0
){
if
(
stderr_file_name
!=
NULL
&&
*
stderr_file_name
!=
'\0'
){
int
fd
;
fd
=
open
(
stderr_file_name
,
O_CREAT
|
O_TRUNC
|
O_WRONLY
,
0777
);
if
(
fd
!=-
1
){
dup2
(
fd
,
1
);
close
(
fd
);
}
}
result
=
execv
(
argv
[
0
],
argv
);
else
if
(
pid
!=-
1
)
waitpid
(
pid
,
&
status
,
0
);
}
}
else
if
(
pid
!=-
1
)
result
=
waitpid
(
pid
,
status_p
,
0
);
}
else
result
=-
1
;
return
result
;
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment