The ulimit -c unlimited can also be done by the app via getrlimit and setrlimit. e.g.
#include <unistd.h>
#include <signal.h>
#include <sys/resource.h>
#include <stdio.h>
int main(int argc, char *argv[])
{
pid_t pid = getpid();
struct rlimit l;
int ret = getrlimit(RLIMIT_CORE, &l);
printf("getrlimit returned %d\n", ret);
printf("rlim_cur = %llu\n", l.rlim_cur);
printf("rlim_max = %llu\n", l.rlim_max);
l.rlim_cur = l.rlim_max;
printf("setrlimit returned %d\n", setrlimit(RLIMIT_CORE, &l));
printf("Time to kill myself\n");
kill(pid, SIGBUS);
}