fcntl couldn't lock /dev/null and hangHow 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

Fair Use of Photos as a Derivative Work

Can someone identify this old round connector?

What’s the BrE for “shotgun wedding”?

Is there any problem with students seeing faculty naked in university gym?

The work of mathematicians outside their professional environment

Does SQL Server's serializable isolation level lock entire table

In 1700s, why was 'books that never read' grammatical?

Choice of solvent during thin layer chromatography

Can 35 mm film which went through a washing machine still be developed?

Minimum perfect squares needed to sum up to a target

How to calculate Limit of this sequence

What's the difference between motherboard and chassis?

Is "Ram married his daughter" ambiguous?

Solving a limit using only precalculus algebraic manipulations.

Advices to added homemade symbols

Why is the time of useful consciousness only seconds at high altitudes, when I can hold my breath much longer at ground level?

SHA3-255, one bit less

What kind of nut is this

Can an animal produce milk all the time?

Can/should you swim in zero G?

Is Zhent just the term for any member of the Zhentarim?

How much Money Should I save in Order to Generate $1000/Month for the rest of my life?

Redirect output on-the-fly - looks not possible in Linux, why?

how would i use rm to delete all files without certain wildcard?



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;









1















A minimal working example, but only for my machine:



int main(int argc, char* argv[]) 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, 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, 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 +++









share|improve this question


























  • First thing to look into would be strace.

    – Jos
    Apr 5 at 21:31











  • @Jos Thanks, I added strace output, what else I can look into?

    – qsp
    Apr 5 at 21:43






  • 1





    Why do you want a lock on /dev/null?

    – vidarlo
    Apr 5 at 22:12











  • You are asking fnctl to obtain an exclusive (write) lock l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but if a conflicting lock is held on the file, then wait for that lock to be released". You may be able to see why there is a conflicting lock using lslocks - see How to list processes locking file?. If you don't want fnctl to wait in the case of conflict, then try F_SETLK in place of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem like a good idea to be write-locking /dev/null.

    – steeldriver
    Apr 6 at 13:58


















1















A minimal working example, but only for my machine:



int main(int argc, char* argv[]) 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, 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, 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 +++









share|improve this question


























  • First thing to look into would be strace.

    – Jos
    Apr 5 at 21:31











  • @Jos Thanks, I added strace output, what else I can look into?

    – qsp
    Apr 5 at 21:43






  • 1





    Why do you want a lock on /dev/null?

    – vidarlo
    Apr 5 at 22:12











  • You are asking fnctl to obtain an exclusive (write) lock l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but if a conflicting lock is held on the file, then wait for that lock to be released". You may be able to see why there is a conflicting lock using lslocks - see How to list processes locking file?. If you don't want fnctl to wait in the case of conflict, then try F_SETLK in place of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem like a good idea to be write-locking /dev/null.

    – steeldriver
    Apr 6 at 13:58














1












1








1








A minimal working example, but only for my machine:



int main(int argc, char* argv[]) 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, 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, 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 +++









share|improve this question
















A minimal working example, but only for my machine:



int main(int argc, char* argv[]) 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, 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, 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 5 at 21:43







qsp

















asked Apr 5 at 21:25









qspqsp

931 silver badge10 bronze badges




931 silver badge10 bronze badges















  • First thing to look into would be strace.

    – Jos
    Apr 5 at 21:31











  • @Jos Thanks, I added strace output, what else I can look into?

    – qsp
    Apr 5 at 21:43






  • 1





    Why do you want a lock on /dev/null?

    – vidarlo
    Apr 5 at 22:12











  • You are asking fnctl to obtain an exclusive (write) lock l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but if a conflicting lock is held on the file, then wait for that lock to be released". You may be able to see why there is a conflicting lock using lslocks - see How to list processes locking file?. If you don't want fnctl to wait in the case of conflict, then try F_SETLK in place of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem like a good idea to be write-locking /dev/null.

    – steeldriver
    Apr 6 at 13:58


















  • First thing to look into would be strace.

    – Jos
    Apr 5 at 21:31











  • @Jos Thanks, I added strace output, what else I can look into?

    – qsp
    Apr 5 at 21:43






  • 1





    Why do you want a lock on /dev/null?

    – vidarlo
    Apr 5 at 22:12











  • You are asking fnctl to obtain an exclusive (write) lock l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but if a conflicting lock is held on the file, then wait for that lock to be released". You may be able to see why there is a conflicting lock using lslocks - see How to list processes locking file?. If you don't want fnctl to wait in the case of conflict, then try F_SETLK in place of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem like a good idea to be write-locking /dev/null.

    – steeldriver
    Apr 6 at 13:58

















First thing to look into would be strace.

– Jos
Apr 5 at 21:31





First thing to look into would be strace.

– Jos
Apr 5 at 21:31













@Jos Thanks, I added strace output, what else I can look into?

– qsp
Apr 5 at 21:43





@Jos Thanks, I added strace output, what else I can look into?

– qsp
Apr 5 at 21:43




1




1





Why do you want a lock on /dev/null?

– vidarlo
Apr 5 at 22:12





Why do you want a lock on /dev/null?

– vidarlo
Apr 5 at 22:12













You are asking fnctl to obtain an exclusive (write) lock l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but if a conflicting lock is held on the file, then wait for that lock to be released". You may be able to see why there is a conflicting lock using lslocks - see How to list processes locking file?. If you don't want fnctl to wait in the case of conflict, then try F_SETLK in place of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem like a good idea to be write-locking /dev/null.

– steeldriver
Apr 6 at 13:58






You are asking fnctl to obtain an exclusive (write) lock l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but if a conflicting lock is held on the file, then wait for that lock to be released". You may be able to see why there is a conflicting lock using lslocks - see How to list processes locking file?. If you don't want fnctl to wait in the case of conflict, then try F_SETLK in place of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem like a good idea to be write-locking /dev/null.

– steeldriver
Apr 6 at 13:58











1 Answer
1






active

oldest

votes


















0
















I'm answering my own question. @steeldriver's comment was very useful, it helped me to understand what was the problem.




You are asking fnctl to obtain an exclusive (write) lock
l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but
if a conflicting lock is held on the file, then wait for that lock to
be released". You may be able to see why there is a conflicting lock
using lslocks - see How to list processes locking file?. If you don't
want fnctl to wait in the case of conflict, then try F_SETLK in place
of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem
like a good idea to be write-locking /dev/null.




For those who are interested in this problem, it was docker daemon that locked /dev/null on my machine. Some more information can be found here:
https://github.com/moby/moby/issues/31182



As why I need to lock /dev/null, I have a testsuite that writes to /dev/null instead of writing to the network. The testsuite is for a different component, written by a different team based in a different continent. So it is not clear for me either :)






share|improve this answer


























    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/4.0/"u003ecc by-sa 4.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
    );



    );














    draft saved

    draft discarded
















    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

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0
















    I'm answering my own question. @steeldriver's comment was very useful, it helped me to understand what was the problem.




    You are asking fnctl to obtain an exclusive (write) lock
    l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but
    if a conflicting lock is held on the file, then wait for that lock to
    be released". You may be able to see why there is a conflicting lock
    using lslocks - see How to list processes locking file?. If you don't
    want fnctl to wait in the case of conflict, then try F_SETLK in place
    of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem
    like a good idea to be write-locking /dev/null.




    For those who are interested in this problem, it was docker daemon that locked /dev/null on my machine. Some more information can be found here:
    https://github.com/moby/moby/issues/31182



    As why I need to lock /dev/null, I have a testsuite that writes to /dev/null instead of writing to the network. The testsuite is for a different component, written by a different team based in a different continent. So it is not clear for me either :)






    share|improve this answer





























      0
















      I'm answering my own question. @steeldriver's comment was very useful, it helped me to understand what was the problem.




      You are asking fnctl to obtain an exclusive (write) lock
      l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but
      if a conflicting lock is held on the file, then wait for that lock to
      be released". You may be able to see why there is a conflicting lock
      using lslocks - see How to list processes locking file?. If you don't
      want fnctl to wait in the case of conflict, then try F_SETLK in place
      of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem
      like a good idea to be write-locking /dev/null.




      For those who are interested in this problem, it was docker daemon that locked /dev/null on my machine. Some more information can be found here:
      https://github.com/moby/moby/issues/31182



      As why I need to lock /dev/null, I have a testsuite that writes to /dev/null instead of writing to the network. The testsuite is for a different component, written by a different team based in a different continent. So it is not clear for me either :)






      share|improve this answer



























        0














        0










        0









        I'm answering my own question. @steeldriver's comment was very useful, it helped me to understand what was the problem.




        You are asking fnctl to obtain an exclusive (write) lock
        l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but
        if a conflicting lock is held on the file, then wait for that lock to
        be released". You may be able to see why there is a conflicting lock
        using lslocks - see How to list processes locking file?. If you don't
        want fnctl to wait in the case of conflict, then try F_SETLK in place
        of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem
        like a good idea to be write-locking /dev/null.




        For those who are interested in this problem, it was docker daemon that locked /dev/null on my machine. Some more information can be found here:
        https://github.com/moby/moby/issues/31182



        As why I need to lock /dev/null, I have a testsuite that writes to /dev/null instead of writing to the network. The testsuite is for a different component, written by a different team based in a different continent. So it is not clear for me either :)






        share|improve this answer













        I'm answering my own question. @steeldriver's comment was very useful, it helped me to understand what was the problem.




        You are asking fnctl to obtain an exclusive (write) lock
        l_type=F_WRLCK, where (according to man fnctl) F_SETLKW means "... but
        if a conflicting lock is held on the file, then wait for that lock to
        be released". You may be able to see why there is a conflicting lock
        using lslocks - see How to list processes locking file?. If you don't
        want fnctl to wait in the case of conflict, then try F_SETLK in place
        of F_SETLKW. Regardless, @vidarlo 's point applies - it doesn't seem
        like a good idea to be write-locking /dev/null.




        For those who are interested in this problem, it was docker daemon that locked /dev/null on my machine. Some more information can be found here:
        https://github.com/moby/moby/issues/31182



        As why I need to lock /dev/null, I have a testsuite that writes to /dev/null instead of writing to the network. The testsuite is for a different component, written by a different team based in a different continent. So it is not clear for me either :)







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 16 at 21:26









        qspqsp

        931 silver badge10 bronze badges




        931 silver badge10 bronze badges































            draft saved

            draft discarded















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Tamil (spriik) Luke uk diar | Nawigatjuun

            Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

            Where does the image of a data connector as a sharp metal spike originate from?Where does the concept of infected people turning into zombies only after death originate from?Where does the motif of a reanimated human head originate?Where did the notion that Dragons could speak originate?Where does the archetypal image of the 'Grey' alien come from?Where did the suffix '-Man' originate?Where does the notion of being injured or killed by an illusion originate?Where did the term “sophont” originate?Where does the trope of magic spells being driven by advanced technology originate from?Where did the term “the living impaired” originate?