Is waitpid() a Unix standard system call? - unix

My Professor is going to correct our Operating Systems final project in a Mac OS and in a Linux. So we should use only Unix standard system calls. I searched for a list with all standard system calls, but I'm not sure if any of the sites I found is truly reliable. Does anybody knows a good site for Unix standard system calls?
The only system call I used in my project that I'm not sure if it is Unix standard, is waitpid(). Is it standard?

The waitpid() function is specified by the POSIX standard, which is about close as we can get to a standard for UNIX.
References:
POSIX
waitpid()

Related

How does MacOS utilize both APFS and the native UNIX (Darwin) file system?

I am sure everyone here knows that Mac OS made the transition to its own, native filesystem, dubbed "APFS", around the release of iOS 10.
However, it is also commonly known that behind the scenes Darwin (UNIX) is employed for standard libraries, filesystems, and other low-level system services that I have not looked into.
My question is how Apple managed to create seemingly fluid interactions between the longstanding UNIX filesystem and the newer APFS (which, not to mention, has 64-bit inode numbers). Thank you.
Are you talking about storing resource forks? There is a section in the wikipedia entry for resource forks on this:
https://en.wikipedia.org/wiki/Resource_fork#Compatibility_problems

What is the API for UNIX like Win 32 API in windows?

What is the API for Unix like Win 32 API in Windows?
Is that POSIX library for Unix?
POSIX is not a library, it's a set of standards. Citation: POSIX defines the application programming interface (API), along with command line shells and utility interfaces, for software compatible with variants of Unix and other operating systems. So this is comparable to the Windows API in some way.
Not entirely an answer to your question, but if you want to program under Unix, the book Advanced Programming in the UNIX Environment is a classic and a very good starting point.

What is POSIX compliance and how does it affect me?

I keep seeing this come up and every time I look it up I never get a good explanation of what it is or what it means to me.
What is POSIX compliance? How does assuming my program will only be run on POSIX-compliant machines simplify things for me as a programmer? Does it even?
POSIX defines a set of C headers, System Interfaces, a Shell Command Language and Utilities, that a conforming system must implement.
As a developer, you can rely on these standard interfaces being available on every POSIX system. If your program uses the standard interfaces, it can operate on all POSIX systems.
Porting across non-standard systems is more work, as the system interfaces e.g. for multithreading or networking are different.

Portable way to pass file descriptor between different processes

On most UNIX systems passing an open file between processes can be easily done for child/parent processes by fork(); however I need to share a fd "after" the child was already forked.
I've found some webpages telling me that sendmsg() may work for arbitary processes; but that seems very OS dependent and complex. The portlisten seems like the best example I can find, but I'd prefer a good wrapper library like libevent that hides all the magic of kqueue, pool, ....
Does anyone know if there's some library (and portable way) to do this?
Your best bet is to try sending the file descriptor over a Unix domain socket. This is described in Stephens, and in a few places on the web, but I can dig up code for you if you ask nicely.
This will be pretty portable these days; a lot of the things considered "non-portable" way back when (such as mmap!) are extremely common now. If you need to be more portable than "most systems these days," you've got a lot of interesting issues ahead of you, but possibly if you tell us more about what you're doing and what platforms you're working on (perhaps non-Unix POSIX platforms?) we might be able to help out.
There is a Unix domain socket-based mechanism for transferring file descriptors (such as sockets - which cannot be memory mapped, of course) between processes - using the sendmsg() system call.
You can find more in Stevens (as mentioned by Curt Sampson), and also at Wikipedia.
You can find a much more recent question with working code at Sending file descriptor by Linux socket.

OS-independent API to monitor file system?

I would like to experiment with ideas about distributed file synchronization/replication. To make it efficient when the user is working, I would like to implement some kind of daemon to monitor changes in some directory (e.g. /home/user/dirToBeMonitored or c:\docs and setts\user\dirToBeMonitored). So, I could be able to know which filename was added/changed/deleted at every time (or within a reasonable interval).
Is this possible with any high-medium level language?. Do you know some API (and in which language?) to do this?
Thanks.
The APIs are totally different for Windows, Linux, Mac OS X, and any other Unix you can name, it seems. I don't know of any cross-platform library that handles this in a consistent way.
A bonified answer, albeit one that requires a largish library dependency (well-worth it IMO)!
QT provides the QFileSystemwatcher class, which uses the native mechanism of the underlying platform.
Even better, you can use the QT language bindings for Python or Ruby. Here is a simple PyQT4 application which uses QFileSystemWatcher.
Notes
A good reference on on creating deployable PyQT4 apps, especially on OSX but should work for Windows also.
Same solution previously posted here.
Other cross-platform toolkits may also do the trick (for example Gnome's GIO has GFileMonitor, although it is UNIX only and doesn't support OSX's FSEvents mechanism afaik).
In Linux it is called inotify.
And on OS X it's called fsevents. It's an OS-level API, so it's easiest to access from C or C++. It should be accessible from nearly any language, although bindings for your preferred language may not have been written yet.

Resources