Linux 编程段错误(segmentation error)总结
最近一段时间在linux下用C做一些学习和开发,但是由于经验不足,问题多多。而段错误就是让我非常头痛的一个问题。不过,目前写一个一千行左右的代码,也很少出现段错误,或者是即使出现了,也很容易找出来,并且处理掉。
那什么是段错误?段错误为什么是个麻烦事?以及怎么发现程序中的段错误以及如何避免发生段错误呢?
一方面为了给自己的学习做个总结,另一方面由于至今没有找到一个比较全面介绍这个虽然是“particular problem”的问题,所以我来做个抛砖引玉吧。下面就从上面的几个问题出发来探讨一下“Segmentation faults"吧。
目录
1。什么是段错误?
2。为什么段错误这么“麻烦”?
3。编程中通常碰到段错误的地方有哪些?
4。如何发现程序中的段错误并处理掉?
正文
1。什么是段错误?
下面是来自Answers.com的定义:
Quote:
A
segmentation fault (often shortened to segfault) is a particular error
condition that can occur during the operation of computer software. In
short, a segmentation fault occurs when a program attempts to access a
memory location that it is not allowed to access, or attempts to access
a memory location in a way that is not allowed (e.g., attempts to write
to a read-only location, or to overwrite part of the operating system).
Systems based on processors like the Motorola 68000 tend to refer to
these events as Address or Bus errors.
Segmentation is one
approach to memory management and protection in the operating system.
It has been superseded by paging for most purposes, but much of the
terminology of segmentation is still used, "segmentation fault" being
an example. Some operating systems still have segmentation at some
logical level although paging is used as the main memory management
policy.
On Unix-like operating systems, a process that accesses
invalid memory receives the SIGSEGV signal. On Microsoft Windows, a
process that accesses invalid memory receives the
STATUS_ACCESS_VIOLATION exception.
另外,这里有个基本上对照的中文解释,来自http://www.linux999.org/html_sql/3
相关文档:
作业管理
1.将“当前”作业放到后台“暂停”:ctrl+z
2.观察当前后台作业状态:jobs
参数:
-l 除了列出作业号之外同时列出PID
-r:列出仅在后台运行(run)的作业
-s:仅列出暂停的作业
3.将后台作业拿到前台处理:fg
fg %jobnumber (%可有可无)
4.让作业在后台运行:bg
ctrl ......
#pacman -S openssh #安装openssh
安装完成后在/etc/rc.conf的最底部DAEMONS后添加sshd让系统启动时自动启动openssh
DAEMONS=(syslog-ng network netfs crond sshd)
也可手动启动openssl,执行
#/etc/inin.d/sshd start
默认情况下其它电脑是不能通过ssh来访问archlinux的,需要修改两个文件来实现:
/etc/h ......
安装OpenSSH
Ubuntu缺省没有安装SSH Server,使用以下命令安装:
sudo apt-get install openssh-server openssh-client
不过Ubuntu缺省已经安装了ssh client。
配置完成后重起:
sudo /etc/init.d/ssh restart
windows 客户端用putty连接命令shell模式 ......
M. Tim Jones, 顾问工程师, Emulex Corp.
Linux® 内核使用 GNU Compiler Collection (GCC) 套件的几个特殊功能。这些功能包括提供快捷方式和简化以及向编译器提供优化提示等等。了解这些特殊的 GCC 特性,学习如何在 Linux 内核中使用它们。
GCC 和 Linux 是出色的组合。尽管它们是独立的软件,但是 Linux 完全依靠 ......
1、制作logo的方法:
首先选择一个自己喜欢的图片,然后通过GIMP软件将该图片保存为.png格式,
变换方式这个就不说了(very easy),比如保存为linuxlogo.png.
然后将该图片传入到装有Linux PC比如(ubuntu),按照以下顺序你就可以制作一个你喜欢logo
前提你必须安装以下的工具(pngtopnm,pnmquant,pnmtoplainpnm)
$ ......