加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 如何仅为特定应用程序更改核心模式?

发布时间:2020-12-13 22:57:46 所属栏目:Linux 来源:网络整理
导读:我的应用程序要求以特定模式生成核心文件. 如何在不影响其他流程的情况下执行此操作? 当/ proc是只读时,我该怎么做? 解决方法 男人核心告诉我们: Piping core dumps to a program Since kernel 2.6.19,Linux supports an alternate syntax for the /proc/
我的应用程序要求以特定模式生成核心文件.

如何在不影响其他流程的情况下执行此操作?

当/ proc是只读时,我该怎么做?

解决方法

男人核心告诉我们:

Piping core dumps to a program

Since kernel 2.6.19,Linux supports an alternate syntax for the
/proc/sys/kernel/core_pattern file. If the first character of this
file is a pipe symbol (|),then the remainder of the line is
interpreted as a program to be executed. Instead of being written to
a disk file,the core dump is given as standard input to the program.

Note the following points:

  • The program must be specified using an absolute pathname (or a
    pathname relative to the root directory,/),and must immediately
    follow the ‘|’ character.

  • The process created to run the program runs as user and group
    root.

  • Command-line arguments can be supplied to the program (since Linux
    2.6.24),delimited by white space (up to a total line length of
    128 bytes).

  • The command-line arguments can include any of the % specifiers
    listed above. For example,to pass the PID of the process that is
    being dumped,specify %p in an argument.

你可以在那里放一个脚本,例如

| /path/to/myscript %p %s %c

您可以检测哪个进程正在触发coredump

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读