Brgv
Brgv

Reputation: 21

Unable to run docker container which has CPP code pthread_setschedparam()

I have a docker container, which has CPP code in it.

void SetRealtimeThreadPriority()
{
    sched_param const param{ThreadPriorities::Priority()};
    int result = pthread_setschedparam(pthread_self(), ThreadPriorities::Policy(), &param);
    printf("SetRealtimeThreadPriority - result checked for assertion %d \n", result);
    assert(result == 0); (void) result;
}

when I run the exe which has this code in ubuntu machine it works fine, where result printed is 0(zero). but when I run it in container, the assert is failing.

I have gone through multiple threads, man pages, docker run documentation and articles and tried running the container with below options, but no luck.

docker run -it --rm --cap-add SYS_NICE MyContainer
docker run --cap-add=ALL --privileged MyContainer
docker run --cap-add=ALL MyContainer
docker run -it --rm --userns host --cap-add SYS_NICE MyContainer

How can I debug this issue? Im running docker on wsl ubuntu 16.04.

Upvotes: 0

Views: 510

Answers (1)

Tinkerer
Tinkerer

Reputation: 1068

You could insert some code. Perhaps you can tell what is different? For example, #include <sys/capability.h>, and link with ... -lcap, put this:

std::cout << cap_to_text(cap_get_proc(), NULL) << std::endl;

just before the call to pthread_setschedparam(2). Does it display something different inside and outside the container?

Upvotes: 0

Related Questions