bsd

Limitations of Intel Assembly Syntax Compared to AT&T [closed]

江枫思渺然 提交于 2019-11-27 17:02:48
To me, Intel syntax is much easier to read. If I go traipsing through assembly forest concentrating only on Intel syntax, will I miss anything? Is there any reason I would want to switch to AT&T (outside of being able to read others' AT&T assembly)? My first clue is that gdb uses AT&T by default. If this matters, my focus is only on any relation assembly and syntax may have to Linux/BSD and the C language. There is really no advantage to one over the other. I agree though that Intel syntax is much easier to read. Keep in mind that, AFAIK, all GNU tools have the option to use Intel syntax also.

Using select() for non-blocking sockets

旧时模样 提交于 2019-11-27 14:52:13
I am trying to use the select function to have non-blocking i/o between a server and 1 client (no more) where the communication flows nicely (can send at any time and the other will receive without waiting to send). I found a tutorial with some code and tried to adapt it to mine. This is what I have - Server #define PORT "4950" #define STDIN 0 struct sockaddr name; void set_nonblock(int socket) { int flags; flags = fcntl(socket,F_GETFL,0); assert(flags != -1); fcntl(socket, F_SETFL, flags | O_NONBLOCK); } // get sockaddr, IPv4 or IPv6: void *get_in_addr(struct sockaddr *sa) { if (sa->sa_family

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

三世轮回 提交于 2019-11-27 13:17:23
问题 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 ? 回答1: If you would have read the queue.h file from the beginning, you may have got

Get real path of application from pid?

核能气质少年 提交于 2019-11-27 10:22:42
问题 How can I get the process details like name of application & real path of application from process id? I am using Mac OS X. 回答1: 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

find -exec a shell function in Linux?

自古美人都是妖i 提交于 2019-11-27 05:58:33
Is there a way to get find to execute a function I define in the shell? For example: dosomething () { echo "doing something with $1" } find . -exec dosomething {} \; The result of that is: find: dosomething: No such file or directory Is there a way to get find 's -exec to see dosomething ? Adam Rosenfield Since only the shell knows how to run shell functions, you have to run a shell to run a function. You also need to mark your function for export with export -f , otherwise the subshell won't inherit them: export -f dosomething find . -exec bash -c 'dosomething "$0"' {} \; find . | while read

Using regex to tell csplit where to split the file

白昼怎懂夜的黑 提交于 2019-11-27 04:46:07
问题 I have a large text file with content set up like this: --- title: Lorim Ipsum Dolar --- Lorim ipsum content --- title: Excelvier whatever --- Lorim ipsum content goes here. I'm trying to split up this file into individual files using csplit . The individual files would have content formatted like this: --- title: Lorim Ipsum Dolar --- Lorim ipsum content I was hoping to be able to regex the ---, newline & title like so ---\ntitle But I'm not able to select it with… csplit -k products.txt '/-

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

♀尐吖头ヾ 提交于 2019-11-27 04:14:47
问题 This question already has an answer here: sed -i command for in-place editing to work with both GNU sed and BSD/OSX 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 回答1: 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 ''

Not checking close()'s return value: how serious, really?

怎甘沉沦 提交于 2019-11-27 03:27:23
问题 Linux's "man close" warns (SVr4, 4.3BSD, POSIX.1-2001): Not checking the return value of close() is a common but nevertheless serious programming error. It is quite possible that errors on a previous write(2) operation are first reported at the final close(). Not checking the return value when closing the file may lead to silent loss of data. This can especially be observed with NFS and with disk quota. I can believe that this error is common (at least in applications; I'm no kernel hacker).

execve file not found when stracing the very same file!

a 夏天 提交于 2019-11-27 02:10:05
问题 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

How do I use a new-line replacement in a BSD sed?

邮差的信 提交于 2019-11-27 01:49:56
Greetings, how do I perform the following in BSD sed? sed 's/ /\n/g' From the man-page it states that \n will be treated literally within a replacement string, how do I avoid this behavior? Is there an alternate? I'm using Mac OS Snow Leopard, I may install fink to get GNU sed. In a shell, you can do: sed 's/ /\ /g' hitting the enter key after the backslash to insert a newline. Another way: sed -e 's/ /\'$'\n/g' See here . NeronLeVelu For ease of use, i personally often use cr="\n" # or (depending version and OS) cr=" " sed "s/ /\\${cr}/g" so it stays on 1 line. To expand on @sikmir's answer: