title: Dump core if SIGSEGV (in C)?
body: <p>How can I dump the core when my program receives the SIGSEGV signal ? (The server that runs my program has very limited permissions and therefore core dump is disabled by default.)</p>
  
  <p>I have written the following using gcore but I would like to use C functions instead. Can I somehow catch the core and write it to a folder somewhere ?</p>
  
  <pre><code>
  void segfaulthandler(int parameter)
  {
      char gcore[50];
      sprintf(gcore, "gcore -s -c \"core\" %u", getpid());
      system(gcore);
  
      exit(1);
  }
  
  int main(void)
  {
      signal(SIGSEGV, segfaulthandler);
  }
  </code></pre>