'Calculate core pattern by python

In linux, /proc/sys/kernel/core_pattern indicates the location for corefile. From https://man7.org/linux/man-pages/man5/core.5.html, I know there're several types for this location:

  1. if it's a directory, then all corefiles are stored within that directory by the specified format.
  2. if it's starts with |, then we have to calculate the path by the executable with together arguments.

I want to know, if there're existing libraries that could directly get the location?

context: I want to collect corefile which records the memory dump of a segfault happening rarely in server. I know we could write the directory directly to /proc/sys/kernel/core_pattern to change the corefile location, but I don't have that permission unfortunately.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source