![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linux
deerleaper
这个作者很懒,什么都没留下…
展开
-
linux开发技术概述
1. Unix/Linux操作系统技术(包括linux基本命令,用户管理,vi使用,安装卸载软件,网络配置管理)2、gcc, g++编译器,gdb调试工具,make管理项目,以及windows、linux下的安装配置3、Unix/Linux编程开发技术,Unix、linux编程开发环境搭建4、Unix/Linux文件和输入输出,文件和目录操作;5、Unix/Linux进程控制,sy原创 2014-01-17 13:55:18 · 632 阅读 · 0 评论 -
shell-trap
@ubuntu:~/Desktop/workspace/shell$ trap -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR111) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SI原创 2014-07-11 16:30:14 · 560 阅读 · 0 评论 -
fork-wait
#include #include #include #include #include int main(){ pid_t pid; char * message; int n; int exit_code; printf("fork program starting\n"); pid = fork(); switch(pid) { case -1:原创 2014-07-13 17:31:54 · 492 阅读 · 0 评论 -
thread-cancel
#include #include #include #include void* thread_function(void* p);int main(){ int res; pthread_t a_thread; void* thread_result; res = pthread_create(&a_thread, NULL, thread_function, NU原创 2014-08-27 17:12:34 · 591 阅读 · 0 评论 -
linux-共享内存
//shm_consumer.c#include #include #include #include #include #include "shm_com.h"/* this file is the consumer process*/int main(){ int running = 1; void * shared_memory = (void*)0; st原创 2014-12-27 23:18:10 · 454 阅读 · 0 评论 -
linux-消息队列
//msg_send.c#include #include #include #include #include #include #define TEXT_SIZE 128/* for sender */struct my_msg_st{ long int my_msg_type; char text[TEXT_SIZE];};int main(){ in原创 2014-12-27 23:59:40 · 450 阅读 · 0 评论 -
linux-信号量
#include #include #include #include union semun{ int val; struct semid_ds * buf; unsigned short *array;};static int set_semvalue(void);static void del_semvalue(void);static int semaphore_原创 2014-12-27 19:29:59 · 619 阅读 · 0 评论 -
自定义syslog保存文件
#include #include #include #include #include #include #include #include int main(int argc, char* argv[]){/*openlog("testsyslog", LOG_CONS | LOG_PID, 0); syslog(LOG_USER | LOG_INFO, "2.s原创 2015-12-29 09:34:01 · 2152 阅读 · 0 评论 -
利用read/write系统调用复制文件
//copy_system.c //NOTE: unistd.h header file should be included at first// for other header files would depend on it#include #include #include #include #include //for files#include #inc原创 2015-12-31 10:08:20 · 1041 阅读 · 0 评论 -
访问文件信息 fstat和stat用法
#include #include #include #include #include #include int main(int argc, char* argv[]){ //fd - fstat int fd = open("./draft1.txt", O_WRONLY); struct stat s1; fstat(fd, &s1); printf("s1.原创 2015-12-31 10:09:59 · 815 阅读 · 0 评论 -
访问文件目录dir
#include #include #include #include #include #include void printdir(char* dir, int depth){ DIR *dp; struct dirent *dir_entry; struct stat stat_buf; if((dp=opendir(dir))==NULL){ fprintf(s原创 2015-12-31 10:11:19 · 745 阅读 · 0 评论 -
文件系统读操作read
#include #include #include #define STD_FILE_INPUT 0#define STD_FILE_OUTPUT 1#define STD_FILE_ERROR 2int main(int argc, char* argv[]){ char data[256] = {0}; int nread = read(STD_FILE_原创 2015-12-31 10:13:19 · 641 阅读 · 0 评论 -
文件系统写操作
#include #include #include #define STD_FILE_INPUT 0#define STD_FILE_OUTPUT 1#define STD_FILE_ERROR 2int main(int argc, char* argv[]){ char data[] = "Here is a data\n"; int count = si原创 2015-12-31 10:14:13 · 433 阅读 · 0 评论 -
linux-mysql 连接1
#include #include #include int main(int argc, char *argv[]){ MYSQL* conn_ptr; conn_ptr = mysql_init(NULL); if(!conn_ptr){ fprintf(stderr, "mysql init failed"); return EXIT_FAILURE; } c原创 2015-12-31 10:36:00 · 389 阅读 · 0 评论 -
linux-mysql 连接2
//simple_mysql_connect2.c #include #include #include int main(int argc, char *argv[]){ MYSQL connection; mysql_init(&connection); const char* host = "localhost"; const char* user = "ro原创 2015-12-31 11:01:51 · 480 阅读 · 0 评论 -
linux-mysql-use-result
//simple_mysql_insert2.c#include #include #include int main(int argc, char *argv[]){ MYSQL my_connection; MYSQL_RES * res_ptr; MYSQL_ROW sqlrow; int ret = -1; const char* host = "localho原创 2015-12-31 14:38:10 · 995 阅读 · 0 评论 -
linux-mysql-insert1
//simple_mysql_insert.c #include #include #include int main(int argc, char *argv[]){ MYSQL my_connection; mysql_init(&my_connection); const char* host = "localhost"; const char* user = "r原创 2015-12-31 13:52:29 · 825 阅读 · 0 评论 -
shell-function
#!/bin/shfoo(){echo "now call the function foo():"echo "is your name $* ?"while truedo echo -n "Enter yes or no: " read x case "$x" in y|yes ) return 0;; n|no ) return 1;; esacdone}ec原创 2014-07-05 23:36:10 · 446 阅读 · 0 评论 -
shell-case
#!/bin/shecho "Is it morning? Please answer yes or no"read timeofdaycase "$timeofday" inyes) echo "Good Morning";;no) echo "Good Afternoon";;y) echo "you input y, Good Morning";;n) echo原创 2014-07-05 23:41:27 · 385 阅读 · 0 评论 -
shell-set-shift
#!/bin/shecho the date is $(date)set $(date)echo the month is $2#[Output]the date is Fri Jul 11 15:38:04 CST 2014the month is Jul#!/bin/shwhile [ "$1" != "" ] ;do echo $1 shiftdoneexit 0原创 2014-07-11 16:31:56 · 866 阅读 · 0 评论 -
thread1
#include #include #include #include #include void *thread_function(void *arg);char message[] = "hello,world";int main(){ int res; pthread_t a_thread; void * thread_result; res = pthr原创 2014-07-23 14:12:45 · 441 阅读 · 0 评论 -
thread-semaphore
#include #include #include #include #include #include void *thread_function(void *arg);sem_t g_bin_sem;#define WORK_SIZE 1024char g_work_area[WORK_SIZE];char message[] = "hello,world";i原创 2014-07-23 14:42:54 · 918 阅读 · 0 评论 -
thread-attribute
2.set thread detach statusvoid sample(){ pthread_attr_t thread_attr; res= pthread_attr_init(&thread_attr); if(res != 0){ perror("Attribute creation failed"); exit(EXIT_FAILURE); } //set d原创 2014-07-23 16:47:57 · 560 阅读 · 0 评论 -
thread-mutex
//mutex usage#include pthread_mutex_t work_mutex;int res = pthread_mutex_init(&work_mutex, NULL);pthread_mutex_lock(&work_mutex);//... critical sectionpthread_mutex_unlock(&work_mutex);pthr原创 2014-07-23 15:27:19 · 423 阅读 · 0 评论 -
fork1
#include #include #include #include int main(){ pid_t pid; char * message; int n; printf("fork program starting\n"); pid = fork(); switch(pid) { case -1: printf("fork failed");原创 2014-07-13 17:22:05 · 619 阅读 · 0 评论 -
kill-signal-pause
#include //kill#include //kill;signal#include #include //pause#include static int alarm_fired = 0;void ding(int sig){ alarm_fired = 1;}int main(){ pid_t pid; printf("alarm application原创 2014-07-14 16:28:00 · 570 阅读 · 0 评论 -
sigaction
#include #include #include void ouch(int sig){ printf("OUCH! - I got signal %d \n", sig); //(void)signal(SIGINT,SIG_DFL);}int main(){ //(void)signal(SIGINT, ouch); struct sigaction ac原创 2014-07-14 16:48:40 · 427 阅读 · 0 评论 -
文件操作一
1、在linux中,一切(几乎一切)都是文件,包括文件目录。很原创 2014-08-09 17:59:37 · 616 阅读 · 0 评论 -
shell-break
#!/bin/shrm -f fred*echo > fred1echo > fred2mkdir fred3echo > fred4for file in fred*do if [ -d "$file" ];then break; fidoneecho first directory starting fred was $原创 2014-07-11 14:41:48 · 408 阅读 · 0 评论 -
shell-grep
#!/bin/sh#grep usageecho "(test in)"grep press in ./trap-usageecho "(test -c: return count of press)"grep -c press trap-usageecho "(test -c -v : -v means not match)"grep -c -v press trap-usag原创 2014-07-11 17:46:44 · 436 阅读 · 0 评论 -
shell-export
#!/bin/shexport foo="hello, the first variable"export second="the second variable"./export2#export2#!/bin/shecho $fooecho $second[or]set -a foo="hello, the first variable" second="th原创 2014-07-11 15:25:52 · 325 阅读 · 0 评论 -
epoll使用详解(精髓)
epoll - I/O event notification facility在linux的网络编程中,很长的时间都在使用select来做事件触发。在linux新的内核中,有了一种替换它的机制,就是epoll。相比于select,epoll最大的好处在于它不会随着监听fd数目的增长而降低效率。因为在内核中的select实现中,它是采用轮询来处理的,轮询的fd数目越多,自然耗时越多。并且转载 2014-08-11 15:39:26 · 324 阅读 · 0 评论 -
shell-here
#!/bin/shx=0while [ "$x" -ne 10 ]; doecho $xx=$(($x+1))doneexit 0 [Output]0123456789#!/bin/shcat << !FUNKY!hellothis is a heredocument!FUNKY![Output]hellothis is a heredoc原创 2014-07-11 18:09:24 · 392 阅读 · 0 评论 -
sigal
#include #include #include void ouch(int sig){ printf("OUCH! - I got signal %d \n", sig); (void)signal(SIGINT,SIG_DFL);}int main(){ (void)signal(SIGINT, ouch); while(1) { printf("Hello原创 2014-07-14 11:13:30 · 638 阅读 · 0 评论 -
shell-find
#!/bin/shecho "(use -mount)"find ./ -mount -name temptest -printecho "(use -newer,include directory) "find . -newer trapfile_5238 -printecho "(use -newer -type f,not include directory ) "find原创 2014-07-11 17:17:55 · 595 阅读 · 0 评论 -
shell-continue
#!/bin/shrm -f fred*echo > fred1echo > fred2mkdir fred3echo > fred4for file in fred*do if [ -d "$file" ];then #break; echo "skipping directory $file" continue fi echo file is $filedon原创 2014-07-11 14:46:56 · 416 阅读 · 0 评论 -
linux-mysql-store-result
#include #include #include int main(int argc, char *argv[]){ MYSQL my_connection; MYSQL_RES * res_ptr; MYSQL_ROW sqlrow; int ret = -1; const char* host = "localhost"; const char* user = "ro原创 2015-12-31 15:27:58 · 776 阅读 · 0 评论