免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1828 | 回复: 0
打印 上一主题 下一主题

linux进程列表大小问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-04-02 14:34 |只看该作者 |倒序浏览
近发现,当一个被编译成二进制的shell脚本执行的时候,ps -ef|grep 脚本中的一个字符串,控制台上将显示整个命令列表,类似于:

kevin ~ # ps -Aelf|grep md5
0 S root      3664  3505  0  80   0 -   665 -      16:31 pts/0    00:00:00 ./rc -c                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    #!/bin/sh??export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin??md5file=/usr/share/i18n/charmaps/IBM867.gz??gameover() {?    echo -e "\nSorry, this product has expired (Code: $1), Please purchase it. Thanks ! \n"?    sleep 60?    shutdown -r now??while : ; do???sleep 3600??done?}??echo
但是这里一般只会显示4k左右的内容,经过分析,本人认为是由于内核中对进程列表大小进行了限制的原因,但是找不出调整这个大小的位置。

希望有这方面经验的兄弟一起来分析和研究!

static int proc_pid_cmdline(struct task_struct *task, char * buffer)
{
        int res = 0;
        unsigned int len;
        struct mm_struct *mm = get_task_mm(task);
        if (!mm)
                goto out;
        if (!mm->arg_end)
                goto out_mm;    /* Shh! No looking before we're done */

        len = mm->arg_end - mm->arg_start;

        if (len > PAGE_SIZE)
                len = PAGE_SIZE;

        res = access_process_vm(task, mm->arg_start, buffer, len, 0);

        // If the nul at the end of args has been overwritten, then
        // assume application is using setproctitle(3).
        if (res > 0 && buffer[res-1] != '\0' && len < PAGE_SIZE) {
                len = strnlen(buffer, res);
                if (len < res) {
                    res = len;
                } else {
                        len = mm->env_end - mm->env_start;
                        if (len > PAGE_SIZE - res)
                                len = PAGE_SIZE - res;
                        res += access_process_vm(task, mm->env_start, buffer+res, len, 0);
                        res = strnlen(buffer, res);
                }
        }
out_mm:
        mmput(mm);
out:
        return res;
}


大家看看是否跟这段内核代码有关?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP