*/
#include <errno.h>
#include <sys/resource.h>
+#include <mach/port.h>
extern int __iopolicysys(int, struct _iopol_param_t *);
+extern void _pthread_clear_qos_tsd(mach_port_t);
int
getiopolicy_np(int iotype, int scope)
{
/* kernel validates the indiv values, no need to repeat it */
struct _iopol_param_t iop_param;
-
+
iop_param.iop_scope = scope;
iop_param.iop_iotype = iotype;
iop_param.iop_policy = policy;
- return( __iopolicysys(IOPOL_CMD_SET, &iop_param));
+ int rv = __iopolicysys(IOPOL_CMD_SET, &iop_param);
+ if (rv == -2) {
+ /* not an actual error but indication that __iopolicysys removed the thread QoS */
+ _pthread_clear_qos_tsd(MACH_PORT_NULL);
+ rv = 0;
+ }
+
+ return rv;
}