Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FFS Gluon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
firmware
FFS Gluon
Commits
e39cbcbd
Unverified
Commit
e39cbcbd
authored
8 years ago
by
Matthias Schiffer
Browse files
Options
Downloads
Patches
Plain Diff
gluon-core: gluon.util: make exec() replace all stdio files with /dev/null
parent
ea12cb77
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
+21
-8
21 additions, 8 deletions
package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
with
21 additions
and
8 deletions
package/gluon-core/luasrc/usr/lib/lua/gluon/util.lua
+
21
−
8
View file @
e39cbcbd
...
@@ -13,13 +13,14 @@ local function do_filter_prefix(input, output, prefix)
...
@@ -13,13 +13,14 @@ local function do_filter_prefix(input, output, prefix)
return
f
return
f
end
end
local
function
close_stdio
(
stream
,
mode
)
local
function
escape_args
(
ret
,
arg0
,
...
)
local
null
=
nixio
.
open
(
'/dev/null'
,
mode
)
if
not
arg0
then
if
null
then
return
ret
nixio
.
dup
(
null
,
nixio
[
stream
])
if
null
:
fileno
()
>
2
then
null
:
close
()
end
end
end
return
escape_args
(
ret
..
"'"
..
string.gsub
(
arg0
,
"'"
,
"'\\''"
)
..
"' "
,
...
)
end
end
...
@@ -76,9 +77,21 @@ function remove_from_set(t, itm)
...
@@ -76,9 +77,21 @@ function remove_from_set(t, itm)
return
changed
return
changed
end
end
function
exec
(
...
)
function
exec
(
...
)
return
os.execute
(
escape_args
(
''
,
'exec'
,
...
))
local
pid
,
errno
,
error
=
nixio
.
fork
()
if
pid
==
0
then
close_stdio
(
'stdin'
,
'r'
)
close_stdio
(
'stdout'
,
'w'
)
close_stdio
(
'stderr'
,
'w'
)
nixio
.
execp
(
...
)
os.exit
(
127
)
elseif
pid
>
0
then
local
wpid
,
status
,
code
=
nixio
.
waitpid
(
pid
)
return
wpid
and
status
==
'exited'
and
code
else
return
nil
,
errno
,
error
end
end
end
-- Removes all lines starting with a prefix from a file, optionally adding a new one
-- Removes all lines starting with a prefix from a file, optionally adding a new one
...
...
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