ChinaUnix.net
相关文章推荐:

unlink系统调用

刚才写了一段小程序,用来防止一个程序在同时被多次运行.代码如下: #include #include #include #include #include #include #include int main(int argc, char** argv) { int fd; if(-1 == (fd = open("unique.file", O_RDONLY | O_CREAT | O_EXCL, 0600))) { printf("该进程已经有一个副本再运行!\n"...

by akei48 - C/C++ - 2007-03-05 14:10:37 阅读(3853) 回复(13)

相关讨论

当在一个进程中unlink一个文件时,该文件虽然已经被unlink了,但是其所占空间并没有立即被释放,等到整个进程结束时,内核要关闭所有打开的文件时,这个空间才真正被释放。对于文件来说,该命令相当于remove,对于目录来说,该命令相当于rmdir。 当要unlink一个文件时,除了必需对包含该目录项的目录具有写权限外,还必需具备下列条件之一: 拥有该文件 拥有该目录 具有超级用户优先权 如习题4.19中一般用户无法unlink/dev/fd/1这...

by carol79 - Linux文档专区 - 2007-01-08 22:25:49 阅读(638) 回复(0)

unlink函数(删除文件) 使用格式如下: retval = unlink(filename) ; 在运行完上述系统调用后,如果成功,则系统会返回0给变量retval,如果运行失败,则系统会返回-1给变量retval。 Code: include "lyl.h" main(int argc,char *argv[]) { int handle ; int ret_code ; if ( argc != 2 ) { printf("sorry input error\n") ; exit(1) ; } ret_code = unlink(argv[1]) ; if...

by cocoa1227 - Linux文档专区 - 2006-09-20 12:32:17 阅读(999) 回复(0)

今天看APUE提到,unlink函数使文件引用数减一,当引用数为零时,操作系统就删除文件。但若有进程已经打开文件,则只有最后一个引用该文件的文件描述符关闭,该文件才会被删除。 但平时用ubuntu的时候,即使用gedit之类的编辑器打开了文件,依旧可以删除,只是退出时会询问是否保存为新文件。这是因为gedit使用open之后就立刻调用了unlink吗? 理解不了为什么可以在打开的情况下删除。。。

by john737 - Linux环境编程 - 2010-11-29 11:07:57 阅读(7984) 回复(2)

如何修改代码才能让shell执行之后删除临时文件 [code] #include #include #include main() { int fd,size; char template[]="/tmp/template-XXXXXX"; char s[]="Linux Programmer1!\n"; char r[]="Linux Programmer2!\n"; fd=mkstemp(template); write(fd,s,sizeof(s)); write(fd,r,sizeof(r)); execlp("cat","cat",template,(char *)0); unlink(template); ...

by jxg945 - C/C++ - 2009-12-19 22:09:45 阅读(3043) 回复(9)

才开始看aupe,关于unlink的测试小例子出现问题,程序基本上和树上的一样,但是出现错误 unlink error 为什么会error那?? 程序见附件 大虾们说说。。。谢谢

by computerzanz - Linux环境编程 - 2009-10-07 15:44:26 阅读(1627) 回复(5)

不知道哪里出的问题。 unlink的时候删不掉文件。 这个函数也不复杂啊 …… unlink LIST 我的代码是这样的 130.11.12.12 上的脚本使用了unlink; 130.11.12.7 上的脚本telnet上.12,并执行了12上的脚本。 发现12上的脚本没有把unlink的文件删除掉。telnet去的用户是有权限删除文件的。 如果单独执行12上的脚本是可以删除掉那个文件的 ……

by qfmeal - Perl - 2009-09-14 10:37:11 阅读(1948) 回复(4)

用creat创建了一个文件后,为什么不能用unlink函数将它删除,而在shell下用unlink命令可以删除?

by wonderfulboiz - C/C++ - 2008-04-18 12:51:30 阅读(3333) 回复(2)

unlink函数的作用: -------------------- 删除path指定的目录项,并使得它指向文件的连接数 减1 问题: 如果link_count = 0 时,那么会自动删除文件的实质内容吗?

by anank - Linux环境编程 - 2007-10-12 09:16:50 阅读(6465) 回复(6)

/* unlink utility for GNU. Copyright (C) 2001-2002 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, bu...

by anima - Linux文档专区 - 2006-07-31 00:55:36 阅读(380) 回复(0)

1、unlink dir1后,目录已不存 2、执行df -k 命令,发现文件系统空间未释放 请问各位:有什么办法恢复原目录,或释放空间

by lingzht - AIX - 2005-12-01 10:26:01 阅读(1349) 回复(0)