I'm trying to run a java application , more specifically a jar compiled one, using execve() in c
something like that:
char *cmd[] = {"a.jar"};
execve("a.jar",cmd,NULL);
that is working OK but when I try to limit the number of threads that this program can open using something like that:
struct rlimit rlp;
rlp.rlim_cur = rlp.rlim_max = limit_nproc;
setrlimit(RLIMIT_NPROC,&rlp);
I have a problem with the JVM which would open threads and I'm preventing that so I have this error:
java.lang.OutOfMemoryError: Cannot create GC thread. Out of system resources.
how can I prevent the threads opened in the java application but not those opened by the JVM ? !
please notice , the question is how to prevent user threads but not system threads , I need a restriction to the running environment like what i did in my second code "RLIMIT_NPROC"
and Thanks!