易截截图软件、单文件、免安装、纯绿色、仅160KB

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


相关文档:

linux作业管理(ctrl+z,fg,jobs,kill等)

作业管理
1.将“当前”作业放到后台“暂停”:ctrl+z
2.观察当前后台作业状态:jobs
参数:
-l 除了列出作业号之外同时列出PID  
-r:列出仅在后台运行(run)的作业
-s:仅列出暂停的作业
3.将后台作业拿到前台处理:fg
fg %jobnumber (%可有可无)
4.让作业在后台运行:bg
ctrl ......

linux常用命令


ps -ef|grep tomcat   查看正在启动的线程
cd .. 退回上一极
ls 列出当前目录的文件
kill -9 [线程号]  关闭线程
su - root 登陆账号
阅读(0)| 评论(14)| 分享(0) 较新一篇:转:带搜索分页的gird 较旧一篇:疯子 评论| 赞
周帅 2010-01-26 18:23
su - root 登陆账号
周帅 2010-01-26 19:53
......

面向 DBA 的 Linux Shell 脚本简介

DBA:Linux
面向 DBA 的 Linux Shell 脚本简介
作者:Casimir Saternos
学习一些在 Linux 上安装、运行和维护 Oracle 数据库所需的基本 bash shell 脚本。
本文相关下载:
示例脚本
Oracle 数据库 10g
2005 年 11 月发表
大约 7 年前,Oracle 发布了 Linux 上的第一个商业数据库。从那时起,Oracle、Red Hat 和 ......

Linux中的内存分配和释放之__alloc_pages()函数分析

  在上篇文章的结尾,我们说会在接下来的文章分析分配函数的具体代码,结合我上篇文章说的伙伴机制和冷热区的概念,更好得去理解这个分配过程。好了,我们不再多说了,我们现在开始分析代码吧。
  struct page * fastcall __alloc_pages(unsigned int gfp_mask, unsigned int order,struct zonelist *zonelist) ......

linux开机logo制作

1、制作logo的方法:
 首先选择一个自己喜欢的图片,然后通过GIMP软件将该图片保存为.png格式,
 变换方式这个就不说了(very easy),比如保存为linuxlogo.png.
然后将该图片传入到装有Linux PC比如(ubuntu),按照以下顺序你就可以制作一个你喜欢logo
前提你必须安装以下的工具(pngtopnm,pnmquant,pnmtoplainpnm)
$ ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号