bsd

Why does the doubly linked list in sys/queue.h maintain the address of previous next element?

我怕爱的太早我们不能终老 提交于 2019-11-28 20:53:33
I'm studying sys/queue.h from FreeBSD and I have one question: In sys/queue.h , LIST_ENTRY is defined as follows: #define LIST_ENTRY(type) \ struct { \ struct type *le_next; /* next element */ \ struct type **le_prev; /* address of previous next element */ \ } Why does it maintain the address of previous next element ( struct type **le_prev ) rather than simply previous elment like struct type *le_prev ? If you would have read the queue.h file from the beginning, you may have got following comment: * A list is headed by a single forward pointer (or an array of forward * pointers for a hash

Get real path of application from pid?

人盡茶涼 提交于 2019-11-28 17:17:24
How can I get the process details like name of application & real path of application from process id? I am using Mac OS X. It's quite easy to get the process name / location if you know the PID, just use proc_name or proc_pidpath. Have a look at the following example, which provides the process path: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <libproc.h> int main (int argc, char* argv[]) { pid_t pid; int ret; char pathbuf[PROC_PIDPATHINFO_MAXSIZE]; if ( argc > 1 ) { pid = (pid_t) atoi(argv[1]); ret = proc_pidpath (pid, pathbuf, sizeof(pathbuf)); if

How do I determine the target architecture of static library (.a) on Mac OS X?

依然范特西╮ 提交于 2019-11-28 15:04:10
I'm interested in verifying if a given iPhone static library has been built for ARM or Intel. It's more curiosity than anything. Is there some kind of Mac OS X or BSD specific tool to do this? This post gives an example in Linux. Václav Slavík Another option is lipo ; its output is brief and more readable than otool 's. An example: % lipo -info /usr/lib/libiodbc.a Architectures in the fat file: /usr/lib/libiodbc.a are: x86_64 i386 ppc % lipo -info libnonfatarchive.a input file libnonfatarchive.a is not a fat file Non-fat file: libnonfatarchive.a is architecture: i386 % file will probably tell

bash printf literal verbatim string

一曲冷凌霜 提交于 2019-11-28 09:30:19
问题 To make my code portable, I try to use printf rather than echo . But then printf "-dogs-cats" returns an error. A workaround in the present case is: printf "-";printf "dogs-cats" But is there a general, portable command (or an option with printf ) that will print an arbitrary string as a literal/verbatim, not try to interpret the string as a format? I work in BSD UNIX (on a Mac) but my objective is code that would work in other UNIX flavors as well. 回答1: Just use -- after printf to let it

execve file not found when stracing the very same file!

淺唱寂寞╮ 提交于 2019-11-28 08:21:46
someone i know encountered a problem when running ' lmutil ' so i asked them to strace -f lmutil . Why is execve failing with "No such file"!!! It makes no sense, since I am straceing the very same file!! What exactly is going on here??? strace -f /home/tabitha/Starprogram/FLEXlm_11.7/linux-x86_64-2.3.4/bin/lmutil Output: execve("/home/tabitha/Starprogram/FLEXlm_11.7/linux-x86_64-2.3.4/bin/lmutil", ["/home/tabitha/Starprogram/FLEXlm"...], [/* 38 vars */]) = -1 ENOENT (No such file or directory) dup(2) = 3 fcntl(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE) fstat(3, {st_mode=S_IFCHR|0620, st

linux信号(signal)

扶醉桌前 提交于 2019-11-28 08:10:40
一、signal本质 软中断信号(signal,又简称为信号)用来通知进程发生了异步事件。在软件层次上是对中断机制的一种模拟。 二、signal各种类型 处理动作一项中的字母含义如下 A 缺省的动作是终止进程 B 缺省的动作是忽略此信号 C 缺省的动作是终止进程并进行内核映像转储(dump core) D 缺省的动作是停止进程 E 信号不能被捕获 F 信号不能被忽略 POSIX.1中列出的信号: 信号 值 处理动作 发出信号的原因 ---------------------------------------------------------------------- SIGHUP 1 A 终端挂起或者控制进程终止 SIGINT 2 A 键盘中断(如break键被按下) SIGQUIT 3 C 键盘的退出键被按下 SIGILL 4 C 非法指令 SIGABRT 6 C 由abort(3)发出的退出指令 SIGFPE 8 C 浮点异常 SIGKILL 9 AEF Kill信号 SIGSEGV 11 C 无效的内存引用 SIGPIPE 13 A 管道破裂: 写一个没有读端口的管道 SIGALRM 14 A 由alarm(2)发出的信号 SIGTERM 15 A 终止信号 SIGUSR1 30,10,16 A 用户自定义信号1 SIGUSR2 31,12,17 A 用户自定义信号2

Why can't I use cocoa frameworks in different forked processes?

て烟熏妆下的殇ゞ 提交于 2019-11-28 06:12:20
问题 I was playing with the NSSound class to play a sound in a background process of my own so as to not block user input. I decided to call fork() but that is giving me problems. At the very moment the sound is allocated the forked process crashes. The funny thing is if I construct an example which only calls fork() , then the child process can call NSSound without problems, the crashes come only if I try to use other cocoa APIs before the fork() call. See this example with the crashme?() calls

Linux与Unix到底有什么不同?

不问归期 提交于 2019-11-27 21:04:23
来自:开源中国 原文:Linux vs. Unix: What's the difference? 链接: https:// opensource.com/article/ 18/5/differences-between-linux-and-unix 译者:Tocy, LinuxTech, 琪花亿草, lnovonl, 雪落无痕xdj, kevinlinkai, 无若 如果你是一名20多岁或30多岁的软件开发人员,那么你已成长在一个由Linux主导的世界中。数十年来,它一直是数据中心的重要参与者,尽管很难找到明确的操作系统市场份额的报告,但Linux在数据中心操作系统上的份额可能高达70%,而Windows变体几乎涵盖了所有剩余的比例。使用任何主流公共云的开发人员可以假定目标系统将运行Linux。近些年来,随着Android和基于Linux的嵌入式系统在智能手机、电视、汽车和其他设备中的应用,Linux随处可见的证据比比皆是。 即便如此,大多数软件开发人员,甚至是那些在这场古老的“Linux革命”中成长的软件开发人员,也至少听说过Unix。这听起来与Linux类似,你可能已经听说过人们可以互换地使用这些术语。或者你也许听说过Linux被称为“类Unix”操作系统。 那么,这个Unix是什么呢? 一些漫画种讲到的是坐在发绿光的屏幕后面的精灵般的“老人”,他编写C代码和shell脚本

sed command with -i option (in-place editing) works fine on Ubuntu but not Mac [duplicate]

荒凉一梦 提交于 2019-11-27 18:03:56
This question already has an answer here: I need my sed -i command for in-place editing to work with both GNU sed and BSD/OSX sed 7 answers I know nothing about Sed but need this command (which works fine on Ubuntu) to work on a Mac OSX: sed -i "/ $domain .*#drupalpro/d" /etc/hosts I'm getting: sed: 1: "/etc/hosts": extra characters at the end of h command Ubuntu ships with GNU sed , where the suffix for the -i option is optional. OS X ships with BSD sed , where the suffix is mandatory. Try sed -i '' To complement microtherion's helpful, to-the-point answer : with a portable solution with

Multiple replacements with one sed command

可紊 提交于 2019-11-27 17:15:47
问题 I'm wondering how I can do a multiple find/replace using a single sed statment in Mac OSX . I'm able to do this in Ubuntu but because of the BSD nature of OSX , the command must be slightly altered. So, given a file with the string: "Red Blue Red Blue Black Blue Red Blue Red" I want to run a sed statement that results in the output: "Green Yellow Green Yellow Black Yellow Green Yellow Green" My two sed statements with a qualifying find color1="Green" color2="Yellow" find . -type f -exec sed