Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lxc
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
lxc
Commits
ac825528
Commit
ac825528
authored
Sep 05, 2013
by
Natanael Copa
Committed by
Stéphane Graber
Sep 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lua: implement usleep in C module
So we avoid running os.execute Signed-off-by:
Natanael Copa
<
ncopa@alpinelinux.org
>
Acked-by:
Stéphane Graber
<
stgraber@ubuntu.com
>
parent
12e93188
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
core.c
src/lua-lxc/core.c
+9
-0
lxc-top
src/lxc/lxc-top
+2
-10
No files found.
src/lua-lxc/core.c
View file @
ac825528
...
...
@@ -27,11 +27,13 @@
#include <lauxlib.h>
#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <lxc/lxccontainer.h>
#if LUA_VERSION_NUM < 502
#define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
#define luaL_setfuncs(L,l,n) (assert(n==0), luaL_register(L,NULL,l))
#define luaL_checkunsigned(L,n) luaL_checknumber(L,n)
#endif
#ifdef NO_CHECK_UDATA
...
...
@@ -379,10 +381,17 @@ static int lxc_default_config_path_get(lua_State *L) {
return
1
;
}
/* utility functions */
static
int
lxc_util_usleep
(
lua_State
*
L
)
{
usleep
((
useconds_t
)
luaL_checkunsigned
(
L
,
1
));
return
0
;
}
static
luaL_Reg
lxc_lib_methods
[]
=
{
{
"version_get"
,
lxc_version_get
},
{
"default_config_path_get"
,
lxc_default_config_path_get
},
{
"container_new"
,
container_new
},
{
"usleep"
,
lxc_util_usleep
},
{
NULL
,
NULL
}
};
...
...
src/lxc/lxc-top
View file @
ac825528
...
...
@@ -22,6 +22,7 @@
--
local
lxc
=
require
(
"lxc"
)
local
core
=
require
(
"lxc.core"
)
local
getopt
=
require
(
"alt_getopt"
)
local
lfs
=
require
(
"lfs"
)
...
...
@@ -95,15 +96,6 @@ function strsisize(size, width)
return
string.format
(
"%3d.00 "
,
size
)
end
function
usleep
(
n
)
if
(
n
~=
0
)
then
ret
=
os.execute
(
"usleep "
..
tonumber
(
n
))
if
(
ret
~=
0
)
then
os.exit
(
0
)
end
end
end
function
tty_lines
()
local
rows
=
25
local
f
=
assert
(
io.popen
(
"stty -a | head -n 1"
))
...
...
@@ -238,5 +230,5 @@ do
end
stats_print
(
string.format
(
"TOTAL (%-2d)"
,
#
containers
),
stats_total
)
io.flush
()
usleep
(
optarg
[
"d"
]
*
1000000
)
core
.
usleep
(
optarg
[
"d"
]
*
1000000
)
end
Write
Preview
Markdown
is supported
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