xianlubird / mydocker

<<自己动手写docker>> 源码

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

miss declaration of close function in /nsenter/nsenter.go

s3341458 opened this issue · comments

in setns.go
should have #include <unistd.h> for close function.

I will make pr later if it is indeed a issue

Thanks for your suggestion. There is two implicit-function-declaration:

# github.com/xianlubird/mydocker/nsenter
nsenter/nsenter.go: In function 'enter_namespace':
nsenter/nsenter.go:36:7: warning: implicit declaration of function 'setns' [-Wimplicit-function-declaration]
   if (setns(fd, 0) == -1) {
       ^~~~~
nsenter/nsenter.go:41:3: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration]
   close(fd);
   ^~~~~

PR welcome.

Test following includes, and those warnings went away.

#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>

cheers, do you need me to make a pr for this? If no you can close it.

@s3341458 Yes, pr welcome for this issue.