/* read the "stdin" and write that to the master
*/
if (pfd[0].revents & POLLIN) {
- read(0, &c, 1);
+ if (read(0, &c, 1) < 0) {
+ lxc_log_syserror("failed to read");
+ goto out_err;
+ }
/* we want to exit the console with Ctrl+a q */
if (c == 1) {
goto out;
wait4q = 0;
- write(master, &c, 1);
+ if (write(master, &c, 1) < 0) {
+ lxc_log_syserror("failed to write");
+ goto out_err;
+ }
}
/* other side has closed the connection */
/* read the master and write to "stdout" */
if (pfd[1].revents & POLLIN) {
- read(master, &c, 1);
+ if (read(master, &c, 1) < 0) {
+ lxc_log_syserror("failed to read");
+ goto out_err;
+ }
printf("%c", c);
fflush(stdout);
}
goto err_child_failed;
}
- asprintf(&val, "%d\n", pid);
- asprintf(&init, LXCPATH "/%s/init", name);
+ if (!asprintf(&val, "%d\n", pid)) {
+ lxc_log_syserror("failed to allocate memory");
+ goto err_child_failed;
+ }
+ if (!asprintf(&init, LXCPATH "/%s/init", name)) {
+ lxc_log_syserror("failed to allocate memory");
+ goto err_child_failed;
+ }
fd = open(init, O_WRONLY|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
if (fd < 0) {
lxc_log_syserror("failed to open '%s'", init);
goto err_child_failed;
}
- asprintf(&val, "%d\n", pid);
+ if (!asprintf(&val, "%d\n", pid)) {
+ lxc_log_syserror("failed to allocate memory");
+ goto err_child_failed;
+ }
snprintf(init, MAXPATHLEN, LXCPATH "/%s/init", name);