Linux编程
king523103
这个作者很懒,什么都没留下…
展开
-
LD_PRELOAD环境变量
无意中遇到了这个环境变量,发现很有意思LD_PRELOAD的本意是,允许程序优先加载指定的动态库。这样能够选择不同的动态库中的相同的函数或者变量。 使用场景是:当使用别人提供的动态库,发现其中某些函数实现不合理。但不能要求别人为你修改源代码并重新生成动态库。在这种情况下,使用LD_PRELOAD可以使用自定义的代码替换别人动态库中的部分代码。这种灵活性也会带来一些负面影响,有心人可原创 2015-07-17 17:14:41 · 2758 阅读 · 0 评论 -
system popen -> exec fork waitpid
应用程序执行shell命令一般使用popen或者system系统调用函数,看看他们的代码可以搞清楚他们的区别。popen/* * popen.c Written by W. Richard Stevens */ #include #include #include #include "ourhdr.h"原创 2015-07-02 15:11:37 · 786 阅读 · 0 评论 -
动态库生成和使用
先看代码:pop.cextern int stack[512];extern int top;int pop(){ if(top<=0) return; top--; return stack[top];}push.cextern int stack[512];extern int top;原创 2015-06-04 18:07:16 · 543 阅读 · 0 评论 -
ELF文件
ELF(Executable and Linking Format)是一种对象文件的格式。他用于描述下列三种文件:可重定向对象文件 典型的是gcc -c main.c main.o 其中main.o就是可重定向对象文件可执行对象文件 典型的gcc main.o -o main main文件就是可执行对象文件可动态链接共享对象文件 常用的pthread.so等就原创 2015-06-02 12:34:16 · 630 阅读 · 0 评论 -
Linux系统 Cache和Buffer
http://blog.csdn.net/turkeyzhou/article/details/6426738中提到了关于buf转载 2014-08-13 13:51:59 · 454 阅读 · 0 评论 -
Linux内存管理和优化
我在做嵌入式项目的时候发现了一个问题:当使用内存比较dashi原创 2014-06-21 23:18:48 · 505 阅读 · 0 评论 -
从main函数启动过程说起
先贴代码:#include const int A=10;static int b=30;static char msg[]="hello";int c;static int add(int a,int b){ return a+b;}void printmsg1(int a,int b){ int d= add(a,b); p原创 2015-06-04 15:13:03 · 1585 阅读 · 0 评论 -
Socket非阻塞连接过程
#include #include #include #include #include #include #include #include #include #include #include static fd_set rset;static fd_set wset;int CanRead(int so原创 2015-05-28 09:15:09 · 580 阅读 · 0 评论