linux
Are some allocators lazy?
On Linux, malloc requests memory with sbrk() or mmap() – either way, your address space is expanded immediately, but Linux does not assign actual pages of physical memory until the first write to the page in question. You can see the address space expansion in the VIRT column, while the actual, physical memory usage in … Read more
What does localhost means inside a Docker container?
From inside a container, localhost always refers to the current container. It never refers to another container, and it never refers to anything else running on your physical system that’s not in the same container. It’s not usually useful to make outbound connections to localhost or configure localhost as your database host. From a shell … Read more
vscode “#include errors detected. Please update your includePath
Although the question mentions Arduino, the following suggestions apply basically any time VSCode tells you to “update your includePath”. What is includePath? The includePath is an attribute in c_cpp_settings.json, which is in the .vscode folder of the main folder you have opened in VSCode using File → Open Folder. You can edit c_cpp_settings.json directly, but … Read more
Linux PID recycling [closed]
As new processes fork in, PIDs will increase to a system-dependent limit and then wrap around. The kernel will not reuse a PID before this wrap-around happens. The limit (maximum number of pids) is /proc/sys/kernel/pid_max. The manual says: /proc/sys/kernel/pid_max (since Linux 2.5.34) This file specifies the value at which PIDs wrap around (i.e., the value … Read more
Why does /bin/sh behave differently to /bin/bash even if one points to the other?
bash looks at the value of $argv[0] (bash is implemented in C) to determine how it was invoked. Its behavior when invoked as sh is documented in the manual: If Bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming … Read more
How to upgrade glibc from version 2.12 to 2.14 on CentOS?
You cannot update glibc on Centos 6 safely. However you can install 2.14 alongside 2.12 easily, then use it to compile projects etc. Here is how: mkdir ~/glibc_install; cd ~/glibc_install wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz tar zxvf glibc-2.14.tar.gz cd glibc-2.14 mkdir build cd build ../configure –prefix=/opt/glibc-2.14 make -j4 sudo make install export LD_LIBRARY_PATH=/opt/glibc-2.14/lib
How do I deal with a filename that starts with the hyphen (-) character?
You can refer to it either using ./-filename or some command will allow you to put it after double dash: rm — -filename
Modify Qt GUI from background worker thread
Important thing about Qt is that you must work with Qt GUI only from GUI thread, that is main thread. That’s why the proper way to do this is to notify main thread from worker, and the code in main thread will actually update text box, progress bar or something else. The best way to … Read more
Return value of sed for no match
as @cnicutar commented, the return code of a command means if the command was executed successfully. has nothing to do with the logic you implemented in the codes/scripts. so if you have: echo “foo”|sed ‘/bar/ s/a/b/’ sed will return 0 but if you write some syntax/expression errors, or the input/file doesn’t exist, sed cannot execute … Read more