linux
在用xrandr设置双屏幕扩展显示的时候,有可能会提示下面的错误:
xrandr: screen cannot be larger than 1680×1680 (desired size 3120×1050)
该错误说明Xorg的虚拟桌面不够大,可以通过使用Xorg.conf的Virtual指令更改虚拟桌面的大小。例如:
Section "ServerLayout" Identifier "Xorg Configured" Screen 0 "Primary Screen" 0 0 EndSectionSection "Monitor" Identifier "Primary Monitor" Modeline "1400x900" 104.23 1400 1480 1632 1864 900 901 904 932 -HSync +Vsync EndSectionSection "Screen" Identifier "Primary Screen" Monitor "Primary Monitor" DefaultColorDepth 24 SubSection "Display" Depth 24 Modes "1400x900" "1024x768" Virtual 3120 1050 EndSubSection EndSectionSection "DRI" Mode 0666 EndSection
有时我们会突然想把一个正在运行中的程序放到后台去执行。由于事先没有准备,很可能忘记重定向输出到文件或者忘记使用screen、nohup一类的命令来跑。下面介绍一个处理这种问题的小技巧。
- 获得程序的进程号(PID)
- 使用gdb调试这个进程。(gdb -p xxx)
- 通过close系统调用关闭标准输出(STDOUT)或者标准错误(STDERR)
- 通过creat系统调用打开一个文件并将其文件描述符通过dup2系统调用复制给标准输出或者标准错误
- 退出调试器。现在可以将程序通过“CTRL+z”, “bg”, “disown“放入后台运行了。具体方法请参考: 让程序在后台运行的几个简单方法
详细操作步骤截图如下
nby:~ $ ps awux | grep [t]op
jianingy 4753 0.1 0.0 2308 1008 pts/2 S+ 17:44 0:00 top -b
nby:~ $ gdb -p 4753
GNU gdb (GDB) 7.0
…
0xb776a424 in __kernel_vsyscall ()
(gdb) call close(1)
$1 = 0
(gdb) call dup2(creat(”/tmp/log”, 0600), 1)
$2 = 1
(gdb) quit
使用本文附件中提供的脚本,可以方便的使用这种方法进行重定向。
参考文献
编译的时候定义宏:-D_LARGEFILE64_SOURCE