`
fanrey
  • 浏览: 251931 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表

奇怪的linker问题

下面这个linker的问题找了3个小时: gcc -o example example.o -Wl -L/home/kensey/cdev/lib -L/usr/lib/x86_64-linux-gnu   -lmysqlclient -lpthread -lz -L/usr/lib/x86_64-linux-gnu -lm -lrt -ldl -lcdev -L/home/kensey/www.tools/gplot-lib -lgplot -L/home/kensey/www.tools/gd1_3ret -lgd -lxml2 -lcurl /usr/bin/ld: /home/kens ...
int    pip[2]; pipe(pip); fork(); /* parent process */ /* Close Read end of the pipe */    close(pip[0]); /* child process */ /* Close Write end of the pipe */    close(pip[1]); strace结果显示错把标准输出关掉了: pipe([1, 11])  close(1)                                = 0 close(11)                            ...

coredump with calloc()

Program terminated with signal 11, Segmentation fault. #0  0x0e0ec2e8 in malloc_consolidate () from /lib/libc.so.6 #1  0x0e0ef21c in _int_malloc () from /lib/libc.so.6 #2  0x0e0f078c in calloc () from /lib/libc.so.6 用valgrind的memcheck检测到有个内存malloc后free了两次,导致再次分配内存就会coredump.
原来是pthread_create后没有调pthread_join或者pthread_detach, 导致memory leak. A  thread may either be joinable or detached.  If a thread is joinable,        then another thread can call pthread_join(3) to wait for the thread  to        terminate  and  fetch its exit status.  Only when a terminated joinable      ...

agentx协议格式

    博客分类:
  • snmp
agentx协议格式: AgentX PDU Header    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    |   h.version   |    h.type     |    h.flags    |  <reserved>   |    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    |                          h.sessionID              ...
用gcc -E可以得到下面的预编译结果: typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__))); typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__))); typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__))); typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__))); QI: An ...

读锁和写锁的区别

 
共享锁(S锁)又称读锁,若事务T对数据对象A加上S锁,则事务T可以读A但不能修改A,其他事务只能再对A加S锁,而不能加X锁,直到T释放A上的S 锁。这保证了其他事务可以读A,但在T释放A上的S锁之前不能对A做任何修改。 排他锁(X锁)又称写锁。若事务T对数据对象A加上X锁,事务T可以读A也可以修改A,其他事务不能再对A加任何锁,直到T释放A上的锁。这保证了其他事务在T释放A上的锁之前不能再读取和修改A。
Linux支持共享库已经有悠久的历史了,不再是什么新概念了。大家都知道如何编译、连接以及动态加载(dlopen/dlsym/dlclose) 共享库。但是,可能很多人,甚至包括一些高手,对共享库相关的一些环境变量认识模糊。当然,不知道这些 ...
用了6个小时解决这个问题. 下面是busybox的login.c的code: pw = NULL; getpwnam_r(username, &pwdstruct, pwdbuf, sizeof(pwdbuf), &pw); if (!pw) goto auth_failed; getpwnam_r()总是返回NULL, 换成getpwnam()也是一样的。 但是自己类似busybox写的下面的代码运行没问题: #include <sys/types.h> #include <stdio.h> #include <pwd.h> #inclu ...
c语言数组排序小结(for beginner)   很多朋友是以谭浩强老师编的《c语言教程》作为学习c语言的入门教程的。书中涉及排序问题一般都以“冒泡法”和“选择法”实现。为了扩大视野,增加学习编程的兴趣,我参阅了有关书籍,整理了几种排序法,写出来同大家共勉。(高手们不要笑,这篇文章是写给出学者的,而且我自己也是只菜鸟,虽然内容陈旧,但值得初学者一看)。   让我们先定义一个整型数组a[n],下面用五种方法对其从小到大排序。   (1)“冒泡法”   冒泡法大家都较熟悉。其原理为从a[0]开始,依次将其和后面的元素比较,若a[0]>a[i],则交换它们,一直比较到a[n]。同理对a ...

syslog协议介绍

 
1、介绍     在Unix类操作系统上,syslog广泛应用于系统日志。syslog日志消息既可以记录在本地文件中,也可以通过网络发送到接收syslog的服务器。接收syslog的服务器可以对多个设备的syslog消息进行统一的存储,或者解析其中的 ...

The TACACS+ Protocol

    博客分类:
  • AAA
 
IETF protocol: http://tools.ietf.org/html/draft-grant-tacacs-02 A free tacacs+ server: http://tacacs.net/ The TACACS+ Protocol                               Version 1.78 Status of This Memo    This memo provides information for the Internet community.  This memo    does not specify an Internet st ...

radius协议(转载)

    博客分类:
  • AAA
转自: http://blog.csdn.net/zhaori/article/details/554004 1、 RADIUS协议的包格式 RADIUS数据包是被封装在UDP的数据域中的。 RADIUS的包数据格式如下所示,各域(Fields)的先后次序是从左到右。     0                   1                   2                   3     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1    +-+-+-+-+-+-+-+-+-+-+-+- ...

gprof(转载)

CPU profiling tool: O'profile, kernel shark, trace-cmd, gprof, perf. Memory tool: mpatrol: mem leak detection              glibc-util: gprof 1.1      简介 gprof实际上只是一个用于读取profile结果文件的工具。gprof采用混合方法来收集程序的统计信息 ...

转载: PAM验证

转载 一.PAM简介 Linux-PAM(linux可插入认证模块)是一套共享库,使本地系统管理员可以随意选择程序的认证方式. 换句话说,不用(重新编写和)重新编译一个包含PAM功能的应用程序,就可以改变它使用的认证机制. 这种方式下,就算升级本地认证机制,也不用修改程序. PAM使用配置文件/etc/pam.conf(或/etc/pam.d/下的文件),来管理对程序的认证方式.应用程序 调用相应的配置文件,从而调用本地的认证模块.模块放置在/lib/security下,以加载动态库的形式进 行调用(dlopen(3)). 像我们使用su命令时,系统会提示你输入root用户的 ...
Global site tag (gtag.js) - Google Analytics