X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Frpm-fake.c;h=dbb4b4c12e23762cd6c823d7f6a1b8c09dd04edd;hb=bea242e7bfd39989a3a748aea2577f831986fcbf;hp=1689e2d1175aed4a0c54babd1f664c9754db9495;hpb=e49176a0372f11f52309284b62fed5c2da98f3ab;p=util-vserver.git diff --git a/src/rpm-fake.c b/src/rpm-fake.c index 1689e2d..dbb4b4c 100644 --- a/src/rpm-fake.c +++ b/src/rpm-fake.c @@ -96,6 +96,8 @@ static unsigned int debug_level = 0; static bool is_initialized = false; +static bool ctx_created = false; + //DECLARE(rpm_execcon); //DECLARE(execv); DECLARE(getpwnam); @@ -245,7 +247,7 @@ setupContext(xid_t xid, char const **xid_str) xid_t rc=VC_NOCTX; if ((xid==VC_DYNAMIC_XID || !vc_is_dynamic_xid(xid)) && - (rc=vc_ctx_create(xid))==VC_NOCTX && + (rc=vc_ctx_create(xid, NULL))==VC_NOCTX && errno!=EEXIST) { perror(ENSC_WRAPPERS_PREFIX "vc_ctx_create()"); exit(255); @@ -270,6 +272,7 @@ setupContext(xid_t xid, char const **xid_str) xid = rc; res = true; + ctx_created = true; } } @@ -510,6 +513,15 @@ exitRPMFake() uint8_t c; if (read(sync_sock, &c, 1)!=1) { /*...*/ } if (write(pw_sock, "Q", 1)!=1) { /*...*/ } + if (ctx_created) { + if (vc_isSupported(vcFEATURE_VWAIT)) { + if (vc_wait_exit(ctx)==-1) { /*...*/ } + } + else { + /* this can race */ + if (read(sync_sock, &c, 1)!=0) { /*...*/} + } + } } }