fix the multi hup event problem.
seams like close event fd doesn't frobid hup event being triggered
again.
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
stdout, stderr and signal loop will try to access exec struct.
right now, we don't have reference of exec for stderr handler.
so in stderr epoll handler, it may access to the already released
exec resource.
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
exec cmd may exit before hyper init watching it's ptmx fd,
so the hup event of ptmx may miss, this will cause the eof
message fail to send out.
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
this patch add a pipe besides the pty for container, and the stderr will be
sent from the stderr session if the session provided in spec.
this intend to support log the stdout and stderr separately.
Signed-off-by: Wang Xu <gnawux@gmail.com>
This is what docker does, and will fix the other part of the issue of
official nginx image problems
Test result:
```
gnawux@sonic:~/go/src/github.com/hyperhq/hyper$ ./hyper run nginx
POD id is pod-SwBxHnRdKH
192.168.123.1 - - [03/Oct/2015:07:06:27 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.35.0" "-"
```
The curl in another term:
```
gnawux@sonic:~/c/hyperstart/build$ curl http://192.168.123.7/
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
```
Signed-off-by: Wang Xu <gnawux@gmail.com>
If one pair of pipe created by socketpair closed, the other side
will receice error, so other side cannot know the exec result of
peer.
Use pipe to replace socketpair.
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
It means set fd block first and send out the type.
And fix the access to exec consurrently, hyper init
should be blocked until do_exec_cmd processes the
exec struct.
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
It happend that pts_loop reads all of the data before the,
SIGCHLD signal being handled, so only hup handler will be triggered,
move the sending eof message to hup handler.
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
1, Hold the the file description of pts device and ptmx in hyper-init process
2, Dup fd to the stdio of Exec cmd
3, Exec cmd exited, no EPOLLHUP event since the file is still open
4, Try to read ptmx fd before close pts fd
4, signal handler get signal SIGCHLD, close the pts fd to trigger EPOLLHUP event
5, EPOLLHUP event is received, send eof message to ttyfd. release exec.
Signed-off-by: Gao feng <omarapazanadi@gmail.com>
It's difficult to encode the json with special characters such as '"', '>'...
encoding and unicoding these characters will change the length of json message,
it's a pain to get bytes contains these characters from json.
This patch allows to read the bytes contains special character outside the json.
for example:
{"container":"c5f67934326d2ecef59fee62148bc9237e2481cd803cc0760a6406da15f4ee60","file":"/tmp/aaa"}sssssss
Signed-off-by: Gao feng <omarapazanadi@gmail.com>