linux学习
文章平均质量分 63
wangyangkobe
这个作者很懒,什么都没留下…
展开
-
进程编程—fork,getpid,exit,_exit
一、要搞清楚fork的执行过程,就必须先讲清楚操作系统中的“进程(process)”概念。一个进程,主要包含三个元素:o. 一个可以执行的程序;o. 和该进程相关联的全部数据(包括变量,内存空间,缓冲区等等);o. 程序的执行上下文(execution context)。 不妨简单理解为,一个进程表示的,就是一个可执行程序的一次执行过程中的一个状态。操作系统对进程的管理,典型的情况,是通过进程表完成的。进程表中的每一个表项,记录的是当前操作系统中一个进程的情况。对于单 CPU的情况而言,每一特定时刻只转载 2010-08-09 09:14:00 · 1232 阅读 · 0 评论 -
Linux下grep命令的详解,cut,sed
1、grep能够接受正则表达式和通配符。grep match_pattern filename一个grep命令可以对多个文件进行搜索:grep "match_object" file1 file2 file3用 - - color 选项可以在输出行中重点标记出匹配到的单词:grep word file - -color=autogrep 通常将match_pattern视为通配符。原创 2013-01-22 22:40:16 · 3696 阅读 · 0 评论 -
Linux常用命令
Linux命令命令行下的快捷键 Ctrl+a:把光标移到行首。 Ctrl+e:把光标移到行尾。 Ctrl+l:清除终端。该快捷操作与在命令行键入clear作用相同。 Ctrl+d:从Shell提示中注销并关闭,使用该快捷键就不必键入exi原创 2011-08-16 14:45:07 · 1331 阅读 · 1 评论 -
Linux下的进程间通信(ipc)
http://linux.chinaitlab.com/administer/829333.htmlhttp://www.ibm.com/developerworks/cn/linux/l-ipc/index.htmlhttp://6xudonghai.blo原创 2011-08-11 10:01:32 · 826 阅读 · 0 评论 -
linux下的source命令
Linux Source命令及脚本的执行方式解析当我修改了/etc/profile文件,我想让它立刻生效,而不用重新登录;这时就想到用source命令,如:source /etc/profile对source进行了学习,并且用它与sh 执行脚本进行了对比,现在总结一下。sourc原创 2011-07-09 19:32:00 · 101960 阅读 · 9 评论 -
Ubuntu下面安装rpm软件包
http://embraceubuntu.com/2005/09/23/installing-using-an-rpm-file/ 1、sudo apt-get update 更新软件源2、sudo apt-get upgrade 对软件升级 3、sudo apt-get install alien 安装alien软件 4、sudo alien -k原创 2011-06-19 18:16:00 · 61 阅读 · 0 评论 -
Linux 系统编程
1、I/O操作#include #include #include #include #include #include #include #include using namespace std;/* function: get the inode of the input file input: file descriptor*/int get_inode(int fd){ struct stat buf; int原创 2011-04-18 13:05:00 · 848 阅读 · 0 评论 -
shell编程
<br />#!/bin/bash#readnameecho "your first name:"read firstnameecho "your last name:"read lastname subnameecho "your full name is ${firstname} ${lastname}!"echo "yout subname is ${subname}"<br />#!/bin/bash#shell1.shecho $"脚本的名字 $0"echo原创 2011-04-09 16:34:00 · 632 阅读 · 0 评论 -
Linux编程技术详解——读书笔记
<br />/* * my.c * * Created on: 2010-12-15 * Author: flybird */#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <stdio.h>#include <fcntl.h>//进程间通信,无名管道(pipe),只能在父子进程或兄弟进程间通信,半双工通信int main() { int f_des[原创 2011-01-02 19:58:00 · 1636 阅读 · 0 评论 -
管道编程
<br />1、简单管道实例<br />#include <unistd.h>#include <stdio.h>#include <string.h>#define MAX_LINE 80#define PIPE_STDIN 0#define PIPE_STDOUT 1int main(void){ const char *str = "A sample message!"; int ret, myPipe[2]; cha原创 2010-09-07 21:31:00 · 805 阅读 · 0 评论 -
消息队列IPC---------用途:进程间通信
<br />0、下面用的头文件 "common.h"<br />/*common头文件*/#define MAX_LINE 80#define MY_MQ_ID 111 //消息IDtypedef struct{ long type;//消息类型 float fval;// user message unsigned int uival;// user message char strval[MAX_LINE + 1]; // user message原创 2010-09-12 13:20:00 · 1217 阅读 · 1 评论 -
进程间通信
<br /><br />进程间通信就是在不同进程之间传播或交换信息,那么不同进程之间存在着什么双方都可以访问的介质呢?进程的用户空间是互相独立的,一般而言是不能互相访问的,唯一的例外是共享内存区。但是,系统空间却是“公共场所”,所以内核显然可以提供这样的条件。除此以外,那就是双方都可以访问的外设了。在这个意义上,两个进程当然也可以通过磁盘上的普通文件交换信息,或者通过“注册表”或其它数据库中的某些表项和记录交换信息。广义上这也是进程间通信的手段,但是一般都不把这算作“进程间通信”。因为那原创 2010-09-12 13:29:00 · 1207 阅读 · 0 评论 -
linux下system函数介绍
相关函数 fork,execve,waitpid,popen表头文件 #i nclude定义函数 int system(const char * string);函数说明 system()会调用fork()产生子进程,由子进程来调用/bin/sh-c string来执行参数string字符串所代表的命令,此命>令执行完后随即返回原调用的进程。在调用system()期间SIGCHLD 信号会被暂时搁置,SIGINT和SIGQUIT 信号则会被忽略。返回值原创 2010-08-09 10:12:00 · 703 阅读 · 0 评论 -
linux进程控制-exit()
<br />#include<stdlib.h><br />void exit(int status);<br />不像fork那么难理解,从exit的名字就能看出,这个系统调用是用来终止一个进程的。无论在程序中的什么位置,只要执行到exit系统调用,进程就会停止剩下的所有操作,清除包括PCB在内的各种数据结构,并终止本进程的运行。请看下面的程序:/* exit_test1.c */<br />#include<stdlib.h><br />main()<br />{<br /> printf("this转载 2010-08-09 09:19:00 · 582 阅读 · 0 评论 -
使用Bash 编写的 TCP 端口扫描器
http://www.oschina.net/translate/tcp-port-scanner-in-bash#!/bin/bashalarm(){ perl -e ' eval { $SIG{ALRM} = sub{die}; alarm shift; system(@ARGV); }; if ($@) { exit 1 } ' "$@";}转载 2013-01-27 14:49:08 · 1658 阅读 · 0 评论