#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "compat.h"
#ifdef VC_ENABLE_API_COMPAT
# include "getctx-compat.hc"
#include "vserver-internal.h"
#include "internal.h"
-#include <unistd.h>
#include <sys/types.h>
ctx_t
vc_X_getctx(pid_t pid)
{
- if (pid==0) pid=getpid();
-
CALL_VC(CALL_VC_COMPAT(vc_X_getctx, pid),
CALL_VC_LEGACY(vc_X_getctx, pid));
}
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "compat.h"
#ifdef VC_ENABLE_API_COMPAT
# include "getinitpid-compat.hc"
#include "vserver-internal.h"
#include "internal.h"
-#include <unistd.h>
#include <sys/types.h>
pid_t
vc_X_getinitpid(pid_t pid)
{
- if (pid==0) pid=getpid();
-
CALL_VC(CALL_VC_COMPAT(vc_X_getinitpid, pid),
CALL_VC_LEGACY(vc_X_getinitpid, pid));
}
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
-#include "compat.h"
#include "utils-legacy.h"
#include "internal.h"
size_t len;
char * res = 0;
- if (pid<=0 || (uint32_t)(pid)>99999) {
+ if (pid<0 || (uint32_t)(pid)>99999) {
errno = EINVAL;
return 0;
}
- strcpy(status_name, "/proc/");
- len = utilvserver_uint2str(status_name+sizeof("/proc/")-1,
- sizeof(status_name)-sizeof("/proc//status")+1,
- pid, 10);
- strcpy(status_name+sizeof("/proc/")+len-1, "/status");
+ if (pid==0) strcpy(status_name, "/proc/self/status");
+ else {
+ strcpy(status_name, "/proc/");
+ len = utilvserver_uint2str(status_name+sizeof("/proc/")-1,
+ sizeof(status_name)-sizeof("/proc//status")+1,
+ pid, 10);
+ strcpy(status_name+sizeof("/proc/")+len-1, "/status");
+ }
fd = open(status_name, O_RDONLY);
if (fd==-1) return 0;