posix

Signal handling and sigemptyset()

眉间皱痕 提交于 2019-12-31 10:22:38
问题 Could anyone please explain in a really easy way to understand what sigemptyset() does? Why is it useful? I've read a bunch of definitions but i just don't understand. From what i gather it tracks the signals that are being used for blocking purposes? I'm not really sure i understand why that would be useful. Is it so we do not get that specific signal recursively? Basic example where sigemptyset() is used: #include <signal.h> #include <stdio.h> #include <unistd.h> int main(){ struct

Signal handling and sigemptyset()

旧街凉风 提交于 2019-12-31 10:22:07
问题 Could anyone please explain in a really easy way to understand what sigemptyset() does? Why is it useful? I've read a bunch of definitions but i just don't understand. From what i gather it tracks the signals that are being used for blocking purposes? I'm not really sure i understand why that would be useful. Is it so we do not get that specific signal recursively? Basic example where sigemptyset() is used: #include <signal.h> #include <stdio.h> #include <unistd.h> int main(){ struct

Is there a POSIX-compliant way of getting local network IP address of my computer?

穿精又带淫゛_ 提交于 2019-12-31 02:24:06
问题 I know this question has been asked a million times in one form or another, but no question gave me a POSIX-compliant way of doing it. I need to get the local network address of my computer without using getifaddrs or any other non POSIX-compliant way of accessing interfaces. Is that possible ? 回答1: There is no direct support for such a thing but you can use udp sockets ( SOCK_DGRAM ) to connect to a known distant address. Since udp sockets are stateless this doesn't do any network traffic.

Split JSON array into separate files/objects

旧城冷巷雨未停 提交于 2019-12-30 10:18:28
问题 I have JSON exported from Cassandra in this format. [ { "correlationId": "2232845a8556cd3219e46ab8", "leg": 0, "tag": "received", "offset": 263128, "len": 30, "prev": { "page": { "file": 0, "page": 0 }, "record": 0 }, "data": "HEAD /healthcheck HTTP/1.1\r\n\r\n" }, { "correlationId": "2232845a8556cd3219e46ab8", "leg": 0, "tag": "sent", "offset": 262971, "len": 157, "prev": { "page": { "file": 10330, "page": 6 }, "record": 1271 }, "data": "HTTP/1.1 200 OK\r\nDate: Wed, 14 Feb 2018 12:57:06 GMT

Detecting that log file has been deleted or truncated on POSIX systems?

ぃ、小莉子 提交于 2019-12-30 09:53:41
问题 Suppose a long-running process writes to a log file. Suppose that log file is kept open indefinitely. Suppose that a careless system administrator deletes that log file. Can the program detect that this has happened? Is it safe to assume that fstat() will report a link count of zero for a deleted file? Truncation, it seems to me, is slightly trickier. In part, it depends on whether the file descriptor is running in O_APPEND mode. If the log file is not running with O_APPEND , then the current

What are Header Files and Library Files? [duplicate]

荒凉一梦 提交于 2019-12-29 14:59:50
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: What's the difference between a header file and a library? Can anyone tell me what's the actual meaning of a header file and a library file and their difference? For example we include header file with .h extension in our program and its just the definition but the actual implementation is defined in library files and this is done at linking stage this is what people say but sometimes we include the library

What are Header Files and Library Files? [duplicate]

佐手、 提交于 2019-12-29 14:57:31
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: What's the difference between a header file and a library? Can anyone tell me what's the actual meaning of a header file and a library file and their difference? For example we include header file with .h extension in our program and its just the definition but the actual implementation is defined in library files and this is done at linking stage this is what people say but sometimes we include the library

Signals and interrupts a comparison

我们两清 提交于 2019-12-29 10:05:51
问题 Based on various references, my subjective definition of signals in Linux is "The triggers that are used to notify the processes about an occurrence of a specific event.Event here may refer to a software exception.Additionally signals may also be used for IPC mechanisms." The questions I have are I presume only exceptions (software interrupts) are notified via signals.What about the case of hardware interrupts. What are the various sources of the signal? To me it looks like kernel is always

Best POSIX way to determine if a filesystem is mounted read only

♀尐吖头ヾ 提交于 2019-12-29 08:38:07
问题 If I have a POSIX system like Linux or Mac OS X, what's the best and most portable way to determine if a path is on a read-only filesystem? I can think of 4 ways off the top of my head: open(2) a file with O_WRONLY - You would need to come up with a unique filename and also pass in O_CREAT and O_EXCL . If it fails and you have an errno of EROFS then you know it's a read-only filesystem. This would have the annoying side effect of actually creating a file you didn't care about, but you could

How do locales work in Linux / POSIX and what transformations are applied?

﹥>﹥吖頭↗ 提交于 2019-12-29 05:20:43
问题 I'm working with huge files of (I hope) UTF-8 text. I can reproduce it using Ubuntu 13.10 (3.11.0-14-generic) and 12.04. While investigating a bug I've encountered strange behavoir $ export LC_ALL=en_US.UTF-8 $ sort part-r-00000 | uniq -d ɥ ɨ ɞ ɧ 251 ɨ ɡ ɞ ɭ ɯ 291 ɢ ɫ ɬ ɜ 301 ɪ ɳ 475 ʈ ʂ 565 $ export LC_ALL=C $ sort part-r-00000 | uniq -d $ # no duplicates found The duplicates also appear when running a custom C++ program that reads the file using std::stringstream - it fails due to