Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uva
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
uva
Commits
99356bfe
Commit
99356bfe
authored
14 years ago
by
Sander Mathijs van Veen
Browse files
Options
Downloads
Patches
Plain Diff
OS: fixed segfault.
parent
5a861f69
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
os/extra/src/main.c
+16
-2
16 additions, 2 deletions
os/extra/src/main.c
with
16 additions
and
2 deletions
os/extra/src/main.c
+
16
−
2
View file @
99356bfe
...
@@ -19,9 +19,20 @@
...
@@ -19,9 +19,20 @@
#include
"input.lex.h"
#include
"input.lex.h"
#include
"input.l.h"
#include
"input.l.h"
/*
* Buffer size of path concatenation.
*/
#define PATH_LENGTH 1024
#define PATH_LENGTH 1024
/*
* When the shell is attached to a terminal, this value is true. If the shell
* is attached to a pipe, this value is false.
*/
int
is_interactive
=
0
;
int
is_interactive
=
0
;
/*
* Toggle debug messages. Only useful dring the development.
*/
int
is_debug_mode
=
1
;
int
is_debug_mode
=
1
;
/*
/*
...
@@ -49,7 +60,6 @@ inline int base10len(unsigned int n) {
...
@@ -49,7 +60,6 @@ inline int base10len(unsigned int n) {
return
len
+
1
;
return
len
+
1
;
}
}
/*
/*
* Display a debug message, when running in debug mode, in stderr.
* Display a debug message, when running in debug mode, in stderr.
*/
*/
...
@@ -133,6 +143,9 @@ shell_args *shell_pop_args() {
...
@@ -133,6 +143,9 @@ shell_args *shell_pop_args() {
return
args
;
return
args
;
}
}
/*
* Execute the binary and its parsed arguments.
*/
void
shell_exec
(
shell_args
*
args
)
{
void
shell_exec
(
shell_args
*
args
)
{
assert
(
args
&&
args
->
arg
);
assert
(
args
&&
args
->
arg
);
shell_debug
(
"exec `%s'"
,
args
->
arg
);
shell_debug
(
"exec `%s'"
,
args
->
arg
);
...
@@ -177,10 +190,11 @@ void shell_exec_process(shell_args *args) {
...
@@ -177,10 +190,11 @@ void shell_exec_process(shell_args *args) {
// Convert argument structure to list of strings. And add a NULL pointer as
// Convert argument structure to list of strings. And add a NULL pointer as
// a marker for the end of the list. The first string should point to the
// a marker for the end of the list. The first string should point to the
// binary being executed.
// binary being executed.
assert
(
argc
>=
1
);
char
**
argv
=
malloc
((
argc
+
1
)
*
sizeof
(
char
*
));
char
**
argv
=
malloc
((
argc
+
1
)
*
sizeof
(
char
*
));
argv
[
0
]
=
bin
;
argv
[
0
]
=
bin
;
shell_args
*
cur
=
args
+
sizeof
(
shell_args
*
);
shell_args
*
cur
=
args
+
sizeof
(
shell_args
*
);
for
(
int
a
=
0
;
a
<
argc
&&
cur
;
cur
=
args
->
next
,
a
++
)
for
(
int
a
=
1
;
a
<
argc
&&
cur
;
cur
=
args
->
next
,
a
++
)
argv
[
a
]
=
strdup
(
cur
->
arg
);
argv
[
a
]
=
strdup
(
cur
->
arg
);
argv
[
argc
]
=
NULL
;
argv
[
argc
]
=
NULL
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment