Complex shell scripts in kernel.core_pattern are not working

Solution Verified - Updated -

Issue

Simple scripts in /proc/sys/kernel/core_pattern work properly but as soon as more complex scripts with spaces are used they seem to be ignored.

The following script works:

# cat core.sh
#!/bin/sh
gzip -c -1 > /tmp/core.gz
# echo "|/root/core.sh" > /proc/sys/kernel/core_pattern 
[root@00559414-server ~]# ./a.out 
Segmentation fault (core dumped)
[root@00559414-server ~]# ls -l /tmp/core.gz 
-rw-r--r--. 1 root root 17794 Mar 19 13:42 /tmp/core.gz

The following will not work:

# echo "|/bin/sh -c \"gzip -c -1 > /tmp/core2.gz\"" > /proc/sys/kernel/core_pattern
[root@00559414-server ~]# ./a.out 
Segmentation fault (core dumped)
# ls -l /tmp/core2.gz
ls: cannot access /tmp/core2.gz: No such file or directory

Environment

RHEL

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content