fcntl couldn't lock /dev/null and hangHow to track down the copy and move operations of files and folders?Get...
Why doesn't a class having private constructor prevent inheriting from this class? How to control which classes can inherit from a certain base?
meaning of に in 本当に?
Can a monk's single staff be considered dual wielded, as per the Dual Wielder feat?
Languages that we cannot (dis)prove to be Context-Free
Can I make popcorn with any corn?
Was any UN Security Council vote triple-vetoed?
Which country benefited the most from UN Security Council vetoes?
Can you really stack all of this on an Opportunity Attack?
Maximum likelihood parameters deviate from posterior distributions
Mortgage Pre-approval / Loan - Apply Alone or with Fiancée?
How to move a thin line with the black arrow in Illustrator?
What's that red-plus icon near a text?
Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)
What does it mean to describe someone as a butt steak?
Today is the Center
How does one intimidate enemies without having the capacity for violence?
Modeling an IP Address
Replacing matching entries in one column of a file by another column from a different file
Perform and show arithmetic with LuaLaTeX
DC-DC converter from low voltage at high current, to high voltage at low current
Why can't I see bouncing of switch on oscilloscope screen?
What would happen to a modern skyscraper if it rains micro blackholes?
Uncaught TypeError: 'set' on proxy: trap returned falsish for property Name
Why doesn't H₄O²⁺ exist?
fcntl couldn't lock /dev/null and hang
How to track down the copy and move operations of files and folders?Get exclusive lock constant? In ctypes it is O_EXLOCKDoes the /dev/null file actually have a fixed size?How to lock files with custom-set password?Lock file and release itHow do I use /dev/sdb1 to reduce the strain on /dev/sda1Lock screen halts file copying in NautilusDifference in file count (Linux and Windows)Moved a folder to /dev. Folder has disappeared after rebooting/dev/null questions
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
A minimal working example, but only for my machine:
int main(int argc, char* argv[]) {
int fd = open ("/dev/null", O_RDWR|O_CREAT);
if (fd < 0) {
printf("Failed to open filen");
}
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
int res = fcntl(fd, F_SETLKW,&lock); // this hangs
if (res < 0) {
printf("Failed to lockn");
}
close (fd);
return (0);
}
The program above hangs only on my machine, and completed instantly on 7 other machines. Is there anything that I can look into to investigate this problem?
strace shows that fcntl was getting stuck when the program (./t) was killed by ^C.
5249 execve("./t", ["./t"], [/* 23 vars */]) = 0
5249 brk(NULL) = 0x1cf6000
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
5249 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
5249 fstat(3, {st_mode=S_IFREG|0644, st_size=98358, ...}) = 0
5249 mmap(NULL, 98358, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f31a1118000
5249 close(3) = 0
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
5249 read(3, "177ELF21133>1Pt2"..., 832) = 832
5249 fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1117000
5249 mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f31a0b42000
5249 mprotect(0x7f31a0d02000, 2097152, PROT_NONE) = 0
5249 mmap(0x7f31a0f02000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f31a0f02000
5249 mmap(0x7f31a0f08000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f31a0f08000
5249 close(3) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1116000
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1115000
5249 arch_prctl(ARCH_SET_FS, 0x7f31a1116700) = 0
5249 mprotect(0x7f31a0f02000, 16384, PROT_READ) = 0
5249 mprotect(0x600000, 4096, PROT_READ) = 0
5249 mprotect(0x7f31a1131000, 4096, PROT_READ) = 0
5249 munmap(0x7f31a1118000, 98358) = 0
5249 open("/dev/null", O_RDWR|O_CREAT, 03777762203636510) = 3
5249 fcntl(3, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
5249 --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
5249 +++ killed by SIGINT +++
files
add a comment |
A minimal working example, but only for my machine:
int main(int argc, char* argv[]) {
int fd = open ("/dev/null", O_RDWR|O_CREAT);
if (fd < 0) {
printf("Failed to open filen");
}
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
int res = fcntl(fd, F_SETLKW,&lock); // this hangs
if (res < 0) {
printf("Failed to lockn");
}
close (fd);
return (0);
}
The program above hangs only on my machine, and completed instantly on 7 other machines. Is there anything that I can look into to investigate this problem?
strace shows that fcntl was getting stuck when the program (./t) was killed by ^C.
5249 execve("./t", ["./t"], [/* 23 vars */]) = 0
5249 brk(NULL) = 0x1cf6000
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
5249 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
5249 fstat(3, {st_mode=S_IFREG|0644, st_size=98358, ...}) = 0
5249 mmap(NULL, 98358, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f31a1118000
5249 close(3) = 0
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
5249 read(3, "177ELF21133>1Pt2"..., 832) = 832
5249 fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1117000
5249 mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f31a0b42000
5249 mprotect(0x7f31a0d02000, 2097152, PROT_NONE) = 0
5249 mmap(0x7f31a0f02000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f31a0f02000
5249 mmap(0x7f31a0f08000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f31a0f08000
5249 close(3) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1116000
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1115000
5249 arch_prctl(ARCH_SET_FS, 0x7f31a1116700) = 0
5249 mprotect(0x7f31a0f02000, 16384, PROT_READ) = 0
5249 mprotect(0x600000, 4096, PROT_READ) = 0
5249 mprotect(0x7f31a1131000, 4096, PROT_READ) = 0
5249 munmap(0x7f31a1118000, 98358) = 0
5249 open("/dev/null", O_RDWR|O_CREAT, 03777762203636510) = 3
5249 fcntl(3, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
5249 --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
5249 +++ killed by SIGINT +++
files
First thing to look into would bestrace.
– Jos
43 mins ago
@Jos Thanks, I added strace output, what else I can look into?
– qsp
31 mins ago
Why do you want a lock on/dev/null?
– vidarlo
2 mins ago
add a comment |
A minimal working example, but only for my machine:
int main(int argc, char* argv[]) {
int fd = open ("/dev/null", O_RDWR|O_CREAT);
if (fd < 0) {
printf("Failed to open filen");
}
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
int res = fcntl(fd, F_SETLKW,&lock); // this hangs
if (res < 0) {
printf("Failed to lockn");
}
close (fd);
return (0);
}
The program above hangs only on my machine, and completed instantly on 7 other machines. Is there anything that I can look into to investigate this problem?
strace shows that fcntl was getting stuck when the program (./t) was killed by ^C.
5249 execve("./t", ["./t"], [/* 23 vars */]) = 0
5249 brk(NULL) = 0x1cf6000
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
5249 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
5249 fstat(3, {st_mode=S_IFREG|0644, st_size=98358, ...}) = 0
5249 mmap(NULL, 98358, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f31a1118000
5249 close(3) = 0
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
5249 read(3, "177ELF21133>1Pt2"..., 832) = 832
5249 fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1117000
5249 mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f31a0b42000
5249 mprotect(0x7f31a0d02000, 2097152, PROT_NONE) = 0
5249 mmap(0x7f31a0f02000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f31a0f02000
5249 mmap(0x7f31a0f08000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f31a0f08000
5249 close(3) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1116000
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1115000
5249 arch_prctl(ARCH_SET_FS, 0x7f31a1116700) = 0
5249 mprotect(0x7f31a0f02000, 16384, PROT_READ) = 0
5249 mprotect(0x600000, 4096, PROT_READ) = 0
5249 mprotect(0x7f31a1131000, 4096, PROT_READ) = 0
5249 munmap(0x7f31a1118000, 98358) = 0
5249 open("/dev/null", O_RDWR|O_CREAT, 03777762203636510) = 3
5249 fcntl(3, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
5249 --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
5249 +++ killed by SIGINT +++
files
A minimal working example, but only for my machine:
int main(int argc, char* argv[]) {
int fd = open ("/dev/null", O_RDWR|O_CREAT);
if (fd < 0) {
printf("Failed to open filen");
}
struct flock lock;
lock.l_type = F_WRLCK;
lock.l_whence = SEEK_SET;
lock.l_start = 0;
lock.l_len = 0;
int res = fcntl(fd, F_SETLKW,&lock); // this hangs
if (res < 0) {
printf("Failed to lockn");
}
close (fd);
return (0);
}
The program above hangs only on my machine, and completed instantly on 7 other machines. Is there anything that I can look into to investigate this problem?
strace shows that fcntl was getting stuck when the program (./t) was killed by ^C.
5249 execve("./t", ["./t"], [/* 23 vars */]) = 0
5249 brk(NULL) = 0x1cf6000
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
5249 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
5249 fstat(3, {st_mode=S_IFREG|0644, st_size=98358, ...}) = 0
5249 mmap(NULL, 98358, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f31a1118000
5249 close(3) = 0
5249 access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
5249 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
5249 read(3, "177ELF21133>1Pt2"..., 832) = 832
5249 fstat(3, {st_mode=S_IFREG|0755, st_size=1868984, ...}) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1117000
5249 mmap(NULL, 3971488, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f31a0b42000
5249 mprotect(0x7f31a0d02000, 2097152, PROT_NONE) = 0
5249 mmap(0x7f31a0f02000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1c0000) = 0x7f31a0f02000
5249 mmap(0x7f31a0f08000, 14752, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f31a0f08000
5249 close(3) = 0
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1116000
5249 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f31a1115000
5249 arch_prctl(ARCH_SET_FS, 0x7f31a1116700) = 0
5249 mprotect(0x7f31a0f02000, 16384, PROT_READ) = 0
5249 mprotect(0x600000, 4096, PROT_READ) = 0
5249 mprotect(0x7f31a1131000, 4096, PROT_READ) = 0
5249 munmap(0x7f31a1118000, 98358) = 0
5249 open("/dev/null", O_RDWR|O_CREAT, 03777762203636510) = 3
5249 fcntl(3, F_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
5249 --- SIGINT {si_signo=SIGINT, si_code=SI_KERNEL} ---
5249 +++ killed by SIGINT +++
files
files
edited 31 mins ago
qsp
asked 50 mins ago
qspqsp
88110
88110
First thing to look into would bestrace.
– Jos
43 mins ago
@Jos Thanks, I added strace output, what else I can look into?
– qsp
31 mins ago
Why do you want a lock on/dev/null?
– vidarlo
2 mins ago
add a comment |
First thing to look into would bestrace.
– Jos
43 mins ago
@Jos Thanks, I added strace output, what else I can look into?
– qsp
31 mins ago
Why do you want a lock on/dev/null?
– vidarlo
2 mins ago
First thing to look into would be
strace.– Jos
43 mins ago
First thing to look into would be
strace.– Jos
43 mins ago
@Jos Thanks, I added strace output, what else I can look into?
– qsp
31 mins ago
@Jos Thanks, I added strace output, what else I can look into?
– qsp
31 mins ago
Why do you want a lock on
/dev/null?– vidarlo
2 mins ago
Why do you want a lock on
/dev/null?– vidarlo
2 mins ago
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1131547%2ffcntl-couldnt-lock-dev-null-and-hang%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1131547%2ffcntl-couldnt-lock-dev-null-and-hang%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
First thing to look into would be
strace.– Jos
43 mins ago
@Jos Thanks, I added strace output, what else I can look into?
– qsp
31 mins ago
Why do you want a lock on
/dev/null?– vidarlo
2 mins ago