红联Linux门户
Linux帮助

apue书中例子运行的错误,请大家帮忙看一下!

发布时间:2010-10-25 21:02:27来源:红联作者:dfdongfang402
我在运行apue书中第四章的关于utime函数的一个例子的时候一直报:text is busy 错误,请大家帮忙看一下

#include "apue.h"
#include
#include

int
main(int argc, char *argv[])
{
int i, fd;
struct stat statbuf;
struct utimbuf timebuf;

for (i = 1; i < argc; i++) {
if (stat(argv[i], &statbuf) < 0) { /* fetch current times */
err_ret("%s: stat error", argv[i]);
continue;
}
if ((fd = open(argv[i], O_RDWR | O_TRUNC)) < 0) { /* truncate */
err_ret("%s: open error", argv[i]);
continue;

}
close(fd);
timebuf.actime = statbuf.st_atime;
timebuf.modtime = statbuf.st_mtime;
if (utime(argv[i], &timebuf) < 0) { /* reset times */
err_ret("%s: utime error", argv[i]);
continue;
}
}
exit(0);
}
文章评论

共有 1 条评论

  1. dwillin 于 2010-10-26 08:29:05发表:

    帮顶