Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
5
rated 0 times [  5] [ 0]  / answers: 1 / hits: 3282  / 2 Years ago, fri, april 15, 2022, 11:09:51

myapp is an application that crashes eventually. I would like to get the core dump of those crashes...



This is the upstart script I have written to achieve this. It doesn't work yet.



description "myupstart"

start on runlevel [2534]
stop on runlevel [!2534]

script

ulimit -c 10000
echo "/var/crash/core.%e.%s.%u.%g.%p.%t" > /proc/sys/kernel/core_pattern

cd /path/to/app
./myapp

end script

respawn


Details:

myapp works with drop of permissions. It starts as root [of course] and then switches to another username/group. Is this a problem?



The following commands work on command line if I start the application manually, but they don't work in the upstart script:



ulimit -c 10000
echo "/var/crash/core.%e.%s.%u.%g.%p.%t" > /proc/sys/kernel/core_pattern


Why this difference?


More From » 14.04

 Answers
5

Try making a separate wrapper bash script with the commands between script and end script and pass that to an exec option in the same upstart file.



Chance are that whatever ulimit -c 10000 does disappears by the time upstart calls ./myapp.



Also note that it isn't quite correct to name your file "upstart script". It is a configuration file. It may happen to contain executable lines but its main purpose is to store configuration and not executable commands.



Addendum: I followd the same logic above, but instead of create another script, I had the idea of do ulimit -c 10000 && ./myapp and it worked! upstart accepted the &&


[#25062] Sunday, April 17, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ainubt

Total Points: 496
Total Questions: 98
Total Answers: 126

Location: Sao Tome and Principe
Member since Wed, Dec 21, 2022
1 Year ago
;