diff --git a/gpMgmt/sbin/packcore b/gpMgmt/sbin/packcore index 43320cf5d2edbd3e32b301d127a94aa582fda5da..a6fdae4b035d2b7fd43cee571fa0afea999db116 100755 --- a/gpMgmt/sbin/packcore +++ b/gpMgmt/sbin/packcore @@ -10,7 +10,7 @@ import shutil import stat import sys from optparse import OptionParser -from subprocess import Popen, PIPE +from subprocess import Popen, PIPE, STDOUT def _getPlatformInfo(): @@ -28,7 +28,17 @@ def _getPlatformInfo(): def _getFileInfo(coreFile): - cmd = Popen(['/usr/bin/file', coreFile], stdout=PIPE) + cmd = Popen(['/usr/bin/file', '--version'], stdout=PIPE, stderr=STDOUT) + fileVersion = cmd.communicate()[0].split()[0].strip() + # file allow setting parameters from command line from version 5.21, refer: + # https://github.com/file/file/commit/6ce24f35cd4a43c4bdd249e8e0c4952c1f8eac67 + # Set ELF program sections processed for core files to suppres "too many + # program headers" output + opts = ['/usr/bin/file'] + if fileVersion >= 'file-5.21': + opts += ['-P', 'elf_phnum=2048'] + opts += [coreFile] + cmd = Popen(opts, stdout=PIPE) return cmd.communicate()[0]