How to run strace on ulimit command?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7

Issue

  • Running strace on ulimit command fails with below error:
# strace ulimit
strace: Can't stat 'ulimit': No such file or directory

Resolution

Below is the workaround for Red Hat Enterprise Linux 6 and Red Hat Enterprise Linux 7

  • Create file named as ulimit under /usr/bin/ directory and edit to call the builtin function ulimit .
# vi /usr/bin/ulimit
#!/bin/sh
builtin ulimit "$@"
  • Make /usr/bin/ulimit executable :
# chmod +x /usr/bin/ulimit
  • After following above steps strace will run on ulimit successfully.
  • Red Hat Enterprise Linux 8 Beta has the /usr/bin/ulimit executable file by default provided by bash rpm:
# rpm -ql bash-4.4.19-6.el8.x86_64 | grep -i ulimit
/usr/bin/ulimit
--
# cat /usr/bin/ulimit
#!/bin/sh
builtin ulimit "$@"

Root Cause

  • ulimit is a builtin function of bash rpm. But when strace runs, it looks for ulimit file and returns error strace: Can't stat 'ulimit': No such file or directory as it could not find it.

Diagnostic Steps

  • ulimit file does not exist by default under any path of the executables. Hence strace returns error when it runs on ulimit.
  • Verification of ulimit by which command, shows file is not present in Red Hat Enterprise Linux 6 and Red Hat Enterprise Linux 7:
# which ulimit
/usr/bin/which: no ulimit in (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments