加入收藏 | 设为首页 | 会员中心 | 我要投稿 应用网_丽江站长网 (http://www.0888zz.com/)- 科技、建站、数据工具、云上网络、机器学习!
当前位置: 首页 > 服务器 > 搭建环境 > Windows > 正文

使用strace查找Emacs启动阻塞的原因

发布时间:2019-10-01 01:30:29 所属栏目:Windows 来源:Darksun
导读:副标题#e# 之前就觉得我的 Emacs 启动好慢,查看启动日志会发现启动到一般的时候会有一个比较长时间的卡顿。 之前一直没有理会它,今天花了点时间探索了一下,发现罪魁祸首居然是 exec-path-from-shell 这个包。 现将探索的过程记录如下: 由于使用了 space

然而,从

  1. --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=11679, si_uid=1000, si_status=0, si_utime=1, si_stime=1} ---
  2. rt_sigreturn({mask=[]}) = -1 EINTR (被中断的系统调用)
  3. read(8,

可以看出,实际上子进程已经退出了(父进程收到 SIGCHLD 信号),父进程确依然在尝试从管道中读取内容,导致的阻塞。

而且从

  1. read(8, "setterm: 347273210347253257 xterm-256color 344"..., 16384) = 51
  2. read(8, "Couldn't get a file descriptor r"..., 16333) = 56
  3. read(8, "/home/lujun9972/.bash_profile: 347"..., 16277) = 72
  4. read(8, "Your display number is 0nTest wh"..., 16205) = 78
  5. read(8, "Fcitx is running correctly.nn==="..., 16127) = 104
  6. read(8, "stdin isn't a tty!n", 16023) = 19
  7. read(8, "__RESULTb269cd09e7ec4e8a115188c"..., 16004) = 298
  8. read(8, 0x7ffd1d39cba6, 15706) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)

看到,子进程的输出似乎是我的交互式登录 bash 启动时的输出(加载了 .bash_profile

在往前翻发现这么一段信息:

  1. readlinkat(AT_FDCWD, "/home", 0x7ffd1d3abb50, 1024) = -1 EINVAL (无效的参数)
  2. readlinkat(AT_FDCWD, "/home/lujun9972", 0x7ffd1d3abf00, 1024) = -1 EINVAL (无效的参数)
  3. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d", 0x7ffd1d3ac2b0, 1024) = -1 EINVAL (无效的参数)
  4. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa", 0x7ffd1d3ac660, 1024) = -1 EINVAL (无效的参数)
  5. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904", 0x7ffd1d3aca10, 1024) = -1 EINVAL (无效的参数)
  6. readlinkat(AT_FDCWD, "/home/lujun9972/.emacs.d/elpa/exec-path-from-shell-20180323.1904/exec-path-from-shell.elc", 0x7ffd1d3acdc0, 1024) = -1 EINVAL (无效的参数)
  7. lseek(7, -2655, SEEK_CUR) = 1441
  8. read(7, "n(defvar exec-path-from-shell-de"..., 4096) = 4096

这很明显是跟 exec-path-from-shell 有关啊。

通过查看 exec-path-from-shell 的实现,发现 exec-path-from-shell 的实现原理是通过实际调启一个 shell,然后输出 PATH 和 MANPATH 的值的。 而且对于 bash 来说,默认的启动参数为 -i -l(可以通过exec-path-from-shell-arguments来设置)。也就是说 bash 会作为交互式的登录shell来启动的,因此会加载 .bash_profile 和 .bashrc

既然发现跟 exec-path-from-shell 这个包有关,而且据说这个包对 Linux 其实意义不大,那不如直接禁用掉好了。

  1. dotspacemacs-excluded-packages '(exec-path-from-shell) 

再次重启Emacs,发现这次启动速度明显快了许多了。

【编辑推荐】

  1. 用于测量磁盘活动的Linux命令
  2. 如何在Linux中删除文本中的回车字符
  3. 教程:使用U盘将Linux Mint安装到Windows笔记本上
  4. 如何在Linux/Windows/MacOS上使用.NET进行开发
  5. 摸鱼也要有技巧 3个Linux命令行工具让你假装很忙
【责任编辑:庞桂玉 TEL:(010)68476606】
点赞 0

(编辑:应用网_丽江站长网)

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

热点阅读