bsd

How can a process inquire, when it was started?

房东的猫 提交于 2019-12-11 04:34:37
问题 Is there a call, that can be used to ask the OS, when the current process started? Of course, one could simply call gettimeofday() at start-up and refer to that once-recorded value through the life of the process, but is there another option? Obviously, the OS keeps the record for each process (one can see it in the output of ps , for example). Can it be queried by the process itself (using C)? An ideal solution would, of course, be cross-platform, but something (Free)BSD-specific is fine too

Portable equivalent of OPEN_MAX

空扰寡人 提交于 2019-12-11 00:55:57
问题 nftw wants a parameter for number of file handles to use, and doesn't seem to have a way to say 'as many as possible'. Specifying 255 seems to work on Linux, but fails on BSD. Apparently OPEN_MAX is the recommended solution on BSD, but I can't use this as it doesn't work on Linux. Is there a portable equivalent of OPEN_MAX that will work on both Linux and BSD? Alternatively, is there a portable number, some number large enough to not slow things down, that is portable for practical purposes

How can I know which architecture an *.a file is built for?

一笑奈何 提交于 2019-12-10 17:34:47
问题 I'm working on mac OS 10.7.4. using Xcode 4.3.2 . I had a *.a static library file from my partner. I want to know which architecture it is built for. Is it ARMv6, ARMv7, i386 or other architecture? Is there any command or method to get info about the architecture of the file? 回答1: You can use otool to find out the architecture(s) of a file: otool man page otool -hv mylibrary.a 回答2: The Unix/Linux file command will tell you what kind of file it is: % file a.out a.out: Mach-O 64-bit executable

gdb error in re-settings breakpoint (cannot access memory)

别说谁变了你拦得住时间么 提交于 2019-12-10 17:08:29
问题 I am trying to get gdb to set a breakpoint in pcbsd10 (freebsd10). I have compiled my code with debug symbols, and here is the output from gdb GNU gdb (GDB) 7.7 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64

How to turn a regular file into a symlink on Linux

為{幸葍}努か 提交于 2019-12-10 03:46:35
问题 I'm writing an (un)archiving tool and the way it is designed it first creates a regular file from the archive before it examines the special attributes and may decide that this item is a symlink, in fact. Note: Before more people misunderstand me for wanting to make a symlink of a file. No, I write the symlink data, i.e. its path, into the file, and then I want to tell the file system that this is a symlink I've been developing this on OS X, where it's possible to turn a regular file into a

What's the expected behavior of open(name, O_CREAT|O_DIRECTORY, mode)?

半世苍凉 提交于 2019-12-09 18:24:12
问题 Despite a careful read of the related standard documentation, I can't understand what's the expected behavior in POSIX compliant systems when a open system call is invoked with flags including O_CREAT|O_DIRECTORY . The standard specifies that If O_CREAT and O_DIRECTORY are set and the requested access mode is neither O_WRONLY nor O_RDWR, the result is unspecified. However it does not specify the behavior of the system with neither (O_CREAT|O_DIRECTORY|O_WRONLY) nor (O_CREAT|O_DIRECTORY|O_RDWR

grep -f on OS X produces segfault

徘徊边缘 提交于 2019-12-09 16:51:36
问题 If you've got a Mac, try this: echo 'abcd*' > grepfile echo 'abc$' >> grepfile echo '^abc' >> grepfile echo "fojeiwuroiuwet\nljfajsljkfabcdddjlfkajlkj\nabcaaa\nzzzabc\n" | grep -f grepfile Here's the version: $ grep --v grep (BSD grep) 2.5.1-FreeBSD This is a machine (a rMBP of the 2012 flavor) that's kept up with Apple's software updates, so I am on 10.8.4. I verified that GNU grep compiled from source does not suffer from this problem. Indeed it is version 2.14, which is a whole lot of

Infinite loop when redirecting file to itself from Unix cat

一世执手 提交于 2019-12-08 02:45:52
问题 I'm trying to concatenate a license to the top of my built sources. I'm use GNU Make. In one of my rules, I have: cat src/license.txt build/3d-tags.js > build/3d-tags.js But this seems to be causing an infinite loop. When I kill the cat command, I see that build/3d-tags is just the contents of src/license.txt over and over again? What's going on? I would have suspected the two files to be concatenated together, and the resulting ouput from cat to be redirected back into build/3d-tags.js. I'm

How to iterate all mounted file systems on OSX

99封情书 提交于 2019-12-07 02:27:23
问题 I am interested in iterating all mounted file systems on OSX (currently running 10.9 Mavericks). I am looking for something similar to getmntent() or the output of the mount shell command (although I want to do it from objective C, so parsing the output of a shell command is obviously not optimal). I have been looking a bit at the disk arbitration framework, and it appears that I could be notified about mount and unmount events using this framework. I may be missing something there, but it

Determine OS during runtime

天涯浪子 提交于 2019-12-07 01:48:44
问题 Neither ISO C nor POSIX offer functionality to determine the underlying OS during runtime. From a theoretical point of view, it doesn't matter since C offers wrappers for the most common system calls, and from a nit-picking point of view, there doesn't even have to be an underlying OS. However, in many real-world scenarios, it has proven helpful to know more about the host environment than C is willing to share, e.g. in order to find out where to store config files or how to call select() ,