int capng_apply_caps_fd(int fd);
This function will write the file based capabilities to the extended attributes of the file that the descriptor was opened against. The bounding set is not included in file based capabilities operations. Note that this function will only work if compiled on a kernel that supports file based capabilities such as 2.6.2 6 and later.
This returns 0 on success, -1 if something besides a regular file is passed, and -2 if a non-root namespace id is being used for rootid.