linux之chdir函数解析
[lingyun@localhost chdir]$ ls
chdir.c
[lingyun@localhost chdir]$ cat chdir.c
/*********************************************************************************
* Copyright: (C) 2013 fulinux<fulinux@sina.com>
* All rights reserved.
*
* Filename: chdir.c
* Description: This file
*
* Version: 1.0.0(08/06/2013~)
* Author: fulinux <fulinux@sina.com>
* ChangeLog: 1, Release initial version on "08/06/2013 03:35:13 PM"
*
********************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
int main(void)
{
if(chdir("/tmp") < 0)
{
perror("chdir");
exit(1);
}
printf("chdir to /tmp successded\n");
exit(0);
}
[lingyun@localhost chdir]$ gcc chdir.c
[lingyun@localhost chdir]$ pwd
/home/lingyun/apue/chdir
[lingyun@localhost chdir]$ ./a.out
chdir to /tmp successded
[lingyun@localhost chdir]$ pwd
/home/lingyun/apue/chdir
[lingyun@localhost chdir]$
执行./a.out程序的shell的当前工作目录没有变,其原因是创建了一个子进程并由该子程执行./a.out程序。记得有一次我把文件系统整个都删了,什么命令都不能执行,但是cd命令可以,apue上说cd命令是直接包含在shell程序中的。
linux之chdir函数解析的更多相关文章
- Linux exec族函数解析
背景 在提到 vfork 函数时,我们提到了这个概念.为了更好地学习与运用,我们对exec族函数进行展开. exec函数族 介绍 有时我们希望子进程去执行另外的程序,exec函数族就提供了一个在进程中 ...
- linux之getcwd函数解析
[lingyun@localhost getcwd]$ cat getcwd.c /********************************************************** ...
- linux之unlink函数解析
[lingyun@localhost unlink]$ cat unlink.c /********************************************************* ...
- linux之access函数解析
[lingyun@localhost access_1]$ ls access.c 实例一: [lingyun@localhost access_1]$ cat access.c /******** ...
- linux之ioctl函数解析
[lingyun@localhost ioctl_1]$ ls ipconfig.c [lingyun@localhost ioctl_1]$ cat ipconfig.c /*********** ...
- linux之umask函数解析
[lingyun@localhost umask_1]$ vim umask.c + umask.c ...
- linux之utime函数解析
[lingyun@localhost utime]$ ls hello utime.c world [lingyun@localhost utime]$ cat utime.c /******* ...
- linux之stat函数解析
[lingyun@localhost stat_1]$ vim stat.c + stat.c ...
- 关于Linux系统basename函数缺陷的思考
某模块作为前台进程独立运行时,运行命令携带命令行参数:作为某平台下守护进程子进程运行时,需要将命令行参数固化在代码里.类似如下写法: char *argv[] = {"./DslDriver ...
随机推荐
- 第19讲- UI组件之_Button、checkbox、radio
第19讲 UI组件之_Button.checkbox.radio 四.按钮Button Button继承自TextView,间接继承自View.当用户对按钮进行操作的时候,触发相应事件,如点击,触摸. ...
- hdu 4055 Number String(dp)
Problem Description The signature of a permutation is a string that is computed as follows: for each ...
- [Redux] Extracting Presentational Components -- AddTodo
The code to be refactored: let nextTodoId = 0; class TodoApp extends Component { render() { const { ...
- 无语的index hint:手工分配哈希区,5小时不出结果,优化后20分钟
同事说,有个语句5个小时不出结果,叫我帮忙看看,于是叫同事发过来.不看不知道,一看吓一跳,3个表关联,强制使用了2个index hint,当中一个表9g,一个表67g,另一个小表40Mb.开发者,总以 ...
- HTTP 503 错误 – 服务不可用 (Service unavailable)
介绍 因暂时超载或临时维护,您的 Web 服务器目前无法处理 HTTP 请求. 其含义是, 这是一个暂时情况,会有一些延误, 过 后将会得到缓解. 有些服务器在这种情况下也许干脆拒绝套接字(socke ...
- css-盒模型,浮动,定位之间的关系
网站布局属性:盒模型:调整元素间距float浮动:竖排的块级元素改成横排position定位:重叠元素,精确控制元素位置 能用盒模型,不用float,能用浮动,不用定位
- compass安装
修改ruby软件包的sources 国外服务器不给力,经常链接失败,换成国内淘宝的:https://ruby.taobao.org/ 先移除本有的sources gem sources --remov ...
- 树状jquery导航条
$(function () { $(".leftsecoundtitle").css({ "display": "none" ...
- visifire 图表属性样式设置说明,字体,阴影设置
- SpringMVC中用@ParamVariable传递的参数包含斜杠(/)时,匹配不了报404错误的解决方案
今天做网站[标签]筛选功能时,出现了这么个奇葩的问题. 我是直接通过<a>标签中href来跳转的,url中包含汉字 <a href="/tags/标签A"> ...