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
90bc298b
Unverified
Commit
90bc298b
authored
Jul 03, 2018
by
2xsec
Committed by
Christian Brauner
Jul 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: cleanup shortlived.c
Signed-off-by:
2xsec
<
dh48.jeong@samsung.com
>
parent
dd63f0e7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
0 deletions
+14
-0
shortlived.c
src/tests/shortlived.c
+14
-0
No files found.
src/tests/shortlived.c
View file @
90bc298b
...
@@ -46,10 +46,12 @@ static int destroy_container(void)
...
@@ -46,10 +46,12 @@ static int destroy_container(void)
perror
(
"fork"
);
perror
(
"fork"
);
return
-
1
;
return
-
1
;
}
}
if
(
pid
==
0
)
{
if
(
pid
==
0
)
{
execlp
(
"lxc-destroy"
,
"lxc-destroy"
,
"-f"
,
"-n"
,
MYNAME
,
NULL
);
execlp
(
"lxc-destroy"
,
"lxc-destroy"
,
"-f"
,
"-n"
,
MYNAME
,
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
again:
again:
ret
=
waitpid
(
pid
,
&
status
,
0
);
ret
=
waitpid
(
pid
,
&
status
,
0
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
...
@@ -58,12 +60,15 @@ again:
...
@@ -58,12 +60,15 @@ again:
perror
(
"waitpid"
);
perror
(
"waitpid"
);
return
-
1
;
return
-
1
;
}
}
if
(
ret
!=
pid
)
if
(
ret
!=
pid
)
goto
again
;
goto
again
;
if
(
!
WIFEXITED
(
status
))
{
// did not exit normally
if
(
!
WIFEXITED
(
status
))
{
// did not exit normally
fprintf
(
stderr
,
"%d: lxc-create exited abnormally
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: lxc-create exited abnormally
\n
"
,
__LINE__
);
return
-
1
;
return
-
1
;
}
}
return
WEXITSTATUS
(
status
);
return
WEXITSTATUS
(
status
);
}
}
...
@@ -76,24 +81,30 @@ static int create_container(void)
...
@@ -76,24 +81,30 @@ static int create_container(void)
perror
(
"fork"
);
perror
(
"fork"
);
return
-
1
;
return
-
1
;
}
}
if
(
pid
==
0
)
{
if
(
pid
==
0
)
{
execlp
(
"lxc-create"
,
"lxc-create"
,
"-t"
,
"busybox"
,
"-n"
,
MYNAME
,
NULL
);
execlp
(
"lxc-create"
,
"lxc-create"
,
"-t"
,
"busybox"
,
"-n"
,
MYNAME
,
NULL
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
again:
again:
ret
=
waitpid
(
pid
,
&
status
,
0
);
ret
=
waitpid
(
pid
,
&
status
,
0
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
if
(
errno
==
EINTR
)
if
(
errno
==
EINTR
)
goto
again
;
goto
again
;
perror
(
"waitpid"
);
perror
(
"waitpid"
);
return
-
1
;
return
-
1
;
}
}
if
(
ret
!=
pid
)
if
(
ret
!=
pid
)
goto
again
;
goto
again
;
if
(
!
WIFEXITED
(
status
))
{
// did not exit normally
if
(
!
WIFEXITED
(
status
))
{
// did not exit normally
fprintf
(
stderr
,
"%d: lxc-create exited abnormally
\n
"
,
__LINE__
);
fprintf
(
stderr
,
"%d: lxc-create exited abnormally
\n
"
,
__LINE__
);
return
-
1
;
return
-
1
;
}
}
return
WEXITSTATUS
(
status
);
return
WEXITSTATUS
(
status
);
}
}
...
@@ -124,6 +135,7 @@ int main(int argc, char *argv[])
...
@@ -124,6 +135,7 @@ int main(int argc, char *argv[])
log
.
prefix
=
"shortlived"
;
log
.
prefix
=
"shortlived"
;
log
.
quiet
=
false
;
log
.
quiet
=
false
;
log
.
lxcpath
=
NULL
;
log
.
lxcpath
=
NULL
;
if
(
lxc_log_init
(
&
log
))
if
(
lxc_log_init
(
&
log
))
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
...
@@ -256,11 +268,13 @@ out:
...
@@ -256,11 +268,13 @@ out:
if
(
fd
>=
0
)
{
if
(
fd
>=
0
)
{
char
buf
[
4096
];
char
buf
[
4096
];
ssize_t
buflen
;
ssize_t
buflen
;
while
((
buflen
=
read
(
fd
,
buf
,
1024
))
>
0
)
{
while
((
buflen
=
read
(
fd
,
buf
,
1024
))
>
0
)
{
buflen
=
write
(
STDERR_FILENO
,
buf
,
buflen
);
buflen
=
write
(
STDERR_FILENO
,
buf
,
buflen
);
if
(
buflen
<=
0
)
if
(
buflen
<=
0
)
break
;
break
;
}
}
close
(
fd
);
close
(
fd
);
}
}
}
}
...
...
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