gpt4 book ai didi

linux - linux "cp"命令流程图

转载 作者:太空宇宙 更新时间:2023-11-04 05:56:50 24 4
gpt4 key购买 nike

我想知道cp怎么办命令被执行。我的意思是它从最顶层到内核然后再返回的流程?它的流量是多少?当我们写 cp 时会发生什么命令以及它是如何发生的?请详细说一下。

最佳答案

foo.c cp之前的内容:

this is foo

strace cp foo.c bar.c 给了我这个:

execve("/bin/cp", ["cp", "foo.c", "bar.c"], [/* 58 vars */]) = 0

//several calls to open, fstat64, mmap2, close

open("foo.c", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0664, st_size=12, ...}) = 0

open("bar.c", O_WRONLY|O_CREAT|O_EXCL|O_LARGEFILE, 0664) = 4
fstat64(4, {st_mode=S_IFREG|0664, st_size=0, ...}) = 0
read(3, "this is foo\n", 32768) = 12
write(4, "this is foo\n", 12) = 12
read(3, "", 32768) = 0
close(4) = 0
close(3) = 0

close(0) = 0 // close stdin
close(1) = 0 // close stdout
close(2) = 0 // close stderr
exit_group(0) = ?

关于linux - linux "cp"命令流程图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3784952/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com