工作中遇到的几个函数....

ftell  函数,      运用实例:ftell(fp) >= size

long ftell(FILE *stream);

The ftell() function obtains the current value of the file position
indicator for the stream pointed to by stream.

unlink 函数:   应用实例:unlink(bakfile)

unlink - call the unlink function to remove the specified file  

unlink FILE
unlink OPTION      --------这里是断开备份文件

strstr 函数: 应用实例:    if(strstr(argv[i],"nofork"

返回子串首次出现的地址,第二个参数为子串,

#include <string.h>

char *strstr(const char *haystack, const char *needle);

The strstr() function finds the first occurrence of the substring nee-
dle in the string haystack. The terminating '' characters are not
compared.

 setpgid  函数             setpgid( 0 , 0 ) == -1

 设置父进程的实际组id       

#include <unistd.h>

int setpgid(pid_t pid, pid_t pgid);

setpgid() sets the PGID of the process specified by pid to pgid. Ifpid is zero, then the process ID of the calling process is used. If pgid is zero,

then the PGID of the process specified by pid is made the same as its process ID. If setpgid() is used to move a process from

one process group to another (as is done by some shells when creating pipelines), both process groups must be part of the same session (see

setsid(2) and credentials(7)). In this case, the pgid specifies an existing process group to be joined and the session ID of that group must match the session ID of the joining process.

syscall  函数,应用实例:pid_t m_tid_thread = syscall(__NR_gettid);

  syscall() 执行一个系统调用,根据指定的参数number和所有系统调用的汇编语言接口来确定调用哪个系统调用。
       系统调用所使用的符号常量可以在头文件里面找到。



Linux中,每个进程有一个pid,类型pid_t,由getpid()取得。Linux下的POSIX线程也有一个id,类型 pthread_t,由pthread_self()取得,该id由线程库维护,其id空间是各个进程独立的(即不同进程中的线程可能有相同的id)。Linux中的POSIX线程库实现的线程其实也是一个进程(LWP),只是该进程与主进程(启动线程的进程)共享一些资源而已,比如代码段,数据段等。
有时候我们可能需要知道线程的真实pid。比如进程P1要向另外一个进程P2中的某个线程发送信号时,既不能使用P2的pid,更不能使用线程的pthread id,而只能使用该线程的真实pid,称为tid。
有一个函数gettid()可以得到tid,但glibc并没有实现该函数,只能通过Linux的系统调用syscall来获取。
原文地址:https://www.cnblogs.com/the-tops/p/5583236.html