Is it normal that bash stat() and access() much, before commands?

Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
Running strace on the bash shell that is instructed to run mkdir provided this output which shows lots of stats prior to execve the actual mkdir binary:
2766 [pid 17371] stat(".", 0750, st_size=17262, ...) = 0
2767 [pid 17371] stat("/usr/local/sbin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT 2767 (No such file or directory)
2768 [pid 17371] stat("/usr/local/bin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT (No such file or directory)
2769 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2770 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2771 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2772 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2773 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2774 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2775 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2776 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2777 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2778 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2779 [pid 17371] execve("/usr/bin/mkdir", ["mkdir", "/tmp"], 0x557ec7e15920 /* 5 vars */) = 0
My question is: Is it normal (and if so for what reason) is /usr/bin/mkdir stat()ed a lot?
The output lines are numbered and in particular I wonder what sense will line 2776 make once 2771 was run already. Also I was under the impression bash could have saved all systemcalls from 2770 onward to the final execve as the stat should have provided the information at once? What am I missing?
I have since sought an explanation and checked how an alternative shell the dash shell would behave it also shows some stat()ing :
2792 [pid 17372] stat("/usr/local/sbin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2793 [pid 17372] stat("/usr/local/bin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2794 [pid 17372] stat("/usr/sbin/mkdir", 0755, st_size=51136, ...) = 0
2795 [pid 17372] execve("/usr/sbin/mkdir", ["mkdir", "/run"], 0x55d8d3453bb8 /* 6 vars */) = 0
I am aware that the lines 2792,2793, similar to the lines 2767, 2768are because of searching the executable in the various directories in the currentPATH`.
If this is discounted then dash only does one single stat and bash does 10. Again raising the question: is this normal?
bash stat dash syscalls
add a comment |Â
up vote
0
down vote
favorite
Running strace on the bash shell that is instructed to run mkdir provided this output which shows lots of stats prior to execve the actual mkdir binary:
2766 [pid 17371] stat(".", 0750, st_size=17262, ...) = 0
2767 [pid 17371] stat("/usr/local/sbin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT 2767 (No such file or directory)
2768 [pid 17371] stat("/usr/local/bin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT (No such file or directory)
2769 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2770 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2771 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2772 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2773 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2774 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2775 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2776 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2777 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2778 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2779 [pid 17371] execve("/usr/bin/mkdir", ["mkdir", "/tmp"], 0x557ec7e15920 /* 5 vars */) = 0
My question is: Is it normal (and if so for what reason) is /usr/bin/mkdir stat()ed a lot?
The output lines are numbered and in particular I wonder what sense will line 2776 make once 2771 was run already. Also I was under the impression bash could have saved all systemcalls from 2770 onward to the final execve as the stat should have provided the information at once? What am I missing?
I have since sought an explanation and checked how an alternative shell the dash shell would behave it also shows some stat()ing :
2792 [pid 17372] stat("/usr/local/sbin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2793 [pid 17372] stat("/usr/local/bin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2794 [pid 17372] stat("/usr/sbin/mkdir", 0755, st_size=51136, ...) = 0
2795 [pid 17372] execve("/usr/sbin/mkdir", ["mkdir", "/run"], 0x55d8d3453bb8 /* 6 vars */) = 0
I am aware that the lines 2792,2793, similar to the lines 2767, 2768are because of searching the executable in the various directories in the currentPATH`.
If this is discounted then dash only does one single stat and bash does 10. Again raising the question: is this normal?
bash stat dash syscalls
add a comment |Â
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Running strace on the bash shell that is instructed to run mkdir provided this output which shows lots of stats prior to execve the actual mkdir binary:
2766 [pid 17371] stat(".", 0750, st_size=17262, ...) = 0
2767 [pid 17371] stat("/usr/local/sbin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT 2767 (No such file or directory)
2768 [pid 17371] stat("/usr/local/bin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT (No such file or directory)
2769 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2770 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2771 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2772 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2773 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2774 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2775 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2776 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2777 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2778 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2779 [pid 17371] execve("/usr/bin/mkdir", ["mkdir", "/tmp"], 0x557ec7e15920 /* 5 vars */) = 0
My question is: Is it normal (and if so for what reason) is /usr/bin/mkdir stat()ed a lot?
The output lines are numbered and in particular I wonder what sense will line 2776 make once 2771 was run already. Also I was under the impression bash could have saved all systemcalls from 2770 onward to the final execve as the stat should have provided the information at once? What am I missing?
I have since sought an explanation and checked how an alternative shell the dash shell would behave it also shows some stat()ing :
2792 [pid 17372] stat("/usr/local/sbin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2793 [pid 17372] stat("/usr/local/bin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2794 [pid 17372] stat("/usr/sbin/mkdir", 0755, st_size=51136, ...) = 0
2795 [pid 17372] execve("/usr/sbin/mkdir", ["mkdir", "/run"], 0x55d8d3453bb8 /* 6 vars */) = 0
I am aware that the lines 2792,2793, similar to the lines 2767, 2768are because of searching the executable in the various directories in the currentPATH`.
If this is discounted then dash only does one single stat and bash does 10. Again raising the question: is this normal?
bash stat dash syscalls
Running strace on the bash shell that is instructed to run mkdir provided this output which shows lots of stats prior to execve the actual mkdir binary:
2766 [pid 17371] stat(".", 0750, st_size=17262, ...) = 0
2767 [pid 17371] stat("/usr/local/sbin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT 2767 (No such file or directory)
2768 [pid 17371] stat("/usr/local/bin/mkdir", 0x7ffd87aad0a0) = -1 ENOENT (No such file or directory)
2769 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2770 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2771 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2772 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2773 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2774 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2775 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2776 [pid 17371] access("/usr/bin/mkdir", X_OK) = 0
2777 [pid 17371] stat("/usr/bin/mkdir", 0755, st_size=51136, ...) = 0
2778 [pid 17371] access("/usr/bin/mkdir", R_OK) = 0
2779 [pid 17371] execve("/usr/bin/mkdir", ["mkdir", "/tmp"], 0x557ec7e15920 /* 5 vars */) = 0
My question is: Is it normal (and if so for what reason) is /usr/bin/mkdir stat()ed a lot?
The output lines are numbered and in particular I wonder what sense will line 2776 make once 2771 was run already. Also I was under the impression bash could have saved all systemcalls from 2770 onward to the final execve as the stat should have provided the information at once? What am I missing?
I have since sought an explanation and checked how an alternative shell the dash shell would behave it also shows some stat()ing :
2792 [pid 17372] stat("/usr/local/sbin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2793 [pid 17372] stat("/usr/local/bin/mkdir", 0x7ffc66010b50) = -1 ENOENT (No such file or directory)
2794 [pid 17372] stat("/usr/sbin/mkdir", 0755, st_size=51136, ...) = 0
2795 [pid 17372] execve("/usr/sbin/mkdir", ["mkdir", "/run"], 0x55d8d3453bb8 /* 6 vars */) = 0
I am aware that the lines 2792,2793, similar to the lines 2767, 2768are because of searching the executable in the various directories in the currentPATH`.
If this is discounted then dash only does one single stat and bash does 10. Again raising the question: is this normal?
bash stat dash syscalls
bash stat dash syscalls
asked 5 mins ago
humanityANDpeace
4,67743451
4,67743451
add a comment |Â
add a comment |Â
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f475877%2fis-it-normal-that-bash-stat-and-access-much-before-commands%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password