Index: trunk/src/kWorker/Makefile.kmk
===================================================================
--- trunk/src/kWorker/Makefile.kmk	(revision 3354)
+++ trunk/src/kWorker/Makefile.kmk	(revision 3355)
@@ -78,4 +78,5 @@
        nt/ntunlink.c \
        nt/kFsCache.c \
+       win_get_processor_group_active_mask.c \
        quote_argv.c \
 	is_console.c \
Index: trunk/src/kWorker/kWorker.c
===================================================================
--- trunk/src/kWorker/kWorker.c	(revision 3354)
+++ trunk/src/kWorker/kWorker.c	(revision 3355)
@@ -55,4 +55,5 @@
 #include "nt/kFsCache.h"
 #include "nt_fullpath.h"
+#include "win_get_processor_group_active_mask.h"
 #include "quote_argv.h"
 #include "md5.h"
@@ -12284,4 +12285,41 @@
 
 
+/**
+ * Helper for main() argument handling that sets the processor group if
+ * possible.
+ */
+static void kwSetProcessorGroup(unsigned long uGroup)
+{
+    typedef BOOL (WINAPI *PFNSETTHREADGROUPAFFINITY)(HANDLE, const GROUP_AFFINITY*, GROUP_AFFINITY *);
+    HMODULE             const hmodKernel32 = GetModuleHandleW(L"KERNEL32.DLL");
+    PFNSETTHREADGROUPAFFINITY pfnSetThreadGroupAffinity;
+
+    pfnSetThreadGroupAffinity = (PFNSETTHREADGROUPAFFINITY)GetProcAddress(hmodKernel32, "SetThreadGroupAffinity");
+    if (pfnSetThreadGroupAffinity)
+    {
+        GROUP_AFFINITY OldAff = { 0,            0, 0, 0, 0 };
+        GROUP_AFFINITY NewAff = { 0, (WORD)uGroup, 0, 0, 0 };
+        NewAff.Mask = win_get_processor_group_active_mask((WORD)uGroup);
+        if (NewAff.Mask && (WORD)uGroup == uGroup)
+        {
+            if (!pfnSetThreadGroupAffinity(GetCurrentThread(), &NewAff, &OldAff))
+                kwErrPrintf("Failed to set processor group to %lu (%p): %u\n", uGroup, NewAff.Mask, GetLastError());
+        }
+        else if (GetLastError() == NO_ERROR)
+            kwErrPrintf("Cannot set processor group to %lu: No active processors in group!\n", uGroup);
+        else
+            kwErrPrintf("Cannot set processor group to %lu: GetLogicalProcessorInformationEx failed: %u\n",
+                        uGroup, GetLastError());
+    }
+    else
+    {
+        OSVERSIONINFOA VerInfo = {0};
+        if (VerInfo.dwMajorVersion > 6 || (VerInfo.dwMajorVersion == 6 && VerInfo.dwMinorVersion >= 1))
+            kwErrPrintf("Cannot set processor group to %lu: SetThreadGroupAffinity no found! (Windows version %lu.%lu)\n",
+                        uGroup, VerInfo.dwMajorVersion, VerInfo.dwMinorVersion);
+    }
+}
+
+
 int main(int argc, char **argv)
 {
@@ -12511,19 +12549,5 @@
                     && *pszEnd == '\0'
                     && uValue == (WORD)uValue)
-                {
-                    typedef BOOL (WINAPI *PFNSETTHREADGROUPAFFINITY)(HANDLE, const GROUP_AFFINITY*, GROUP_AFFINITY *);
-                    PFNSETTHREADGROUPAFFINITY pfnSetThreadGroupAffinity;
-                    pfnSetThreadGroupAffinity = (PFNSETTHREADGROUPAFFINITY)GetProcAddress(GetModuleHandleW(L"KERNEL32.DLL"),
-                                                                                          "SetThreadGroupAffinity");
-                    if (pfnSetThreadGroupAffinity)
-                    {
-                        GROUP_AFFINITY NewAff = { ~(uintptr_t)0, (WORD)uValue, 0, 0, 0 };
-                        GROUP_AFFINITY OldAff = {             0,            0, 0, 0, 0 };
-                        if (!pfnSetThreadGroupAffinity(GetCurrentThread(), &NewAff, &OldAff))
-                            kwErrPrintf("Failed to set processor group to %lu: %u\n", uValue, GetLastError());
-                    }
-                    else
-                        kwErrPrintf("Cannot set processor group to %lu because SetThreadGroupAffinity was not found\n", uValue);
-                }
+                    kwSetProcessorGroup(uValue);
                 else
                     return kwErrPrintfRc(2, "Invalid --priority argument: %s\n", argv[i]);
Index: trunk/src/kmk/kmkbuiltin/kSubmit.c
===================================================================
--- trunk/src/kmk/kmkbuiltin/kSubmit.c	(revision 3354)
+++ trunk/src/kmk/kmkbuiltin/kSubmit.c	(revision 3355)
@@ -588,6 +588,6 @@
                             if (iProcessorGroup >= 0 && g_pfnSetThreadGroupAffinity)
                             {
-                                GROUP_AFFINITY NewAff = { ~(uintptr_t)0, (WORD)iProcessorGroup, 0, 0, 0 };
-                                GROUP_AFFINITY OldAff = {             0,                     0, 0, 0, 0 };
+                                GROUP_AFFINITY OldAff = { 0,                                                    0, 0, 0, 0 };
+                                GROUP_AFFINITY NewAff = { 0 /* == all active apparently */, (WORD)iProcessorGroup, 0, 0, 0 };
                                 if (!g_pfnSetThreadGroupAffinity(ProcInfo.hThread, &NewAff, &OldAff))
                                     warnx(pCtx, "warning: Failed to set processor group to %d: %u\n",
Index: trunk/src/kmk/w32/winchildren.c
===================================================================
--- trunk/src/kmk/w32/winchildren.c	(revision 3354)
+++ trunk/src/kmk/w32/winchildren.c	(revision 3355)
@@ -551,6 +551,6 @@
                         Info.BasicLimitInformation.LimitFlags &= ~JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
                     if (!SetInformationJobObject(hJob, JobObjectExtendedLimitInformation, &Info, sizeof(Info)))
-                        OSN(message, 0, _("SetInformationJobObject(%s,JobObjectExtendedLimitInformation,{%s},) failed: %u"),
-                            pszJobName, win_job_object_mode, GetLastError());
+                        OSSN(message, 0, _("SetInformationJobObject(%s,JobObjectExtendedLimitInformation,{%s},) failed: %u"),
+                             pszJobName, win_job_object_mode, GetLastError());
                 }
                 else
@@ -1283,5 +1283,5 @@
         if (g_cProcessorGroups > 1)
         {
-            GROUP_AFFINITY Affinity = { 0, pWorker->iProcessorGroup, { 0, 0, 0 } };
+            GROUP_AFFINITY Affinity = { 0 /* == all active apparently */, pWorker->iProcessorGroup, { 0, 0, 0 } };
             fRet = g_pfnSetThreadGroupAffinity(ProcInfo.hThread, &Affinity, NULL);
             assert(fRet);
@@ -2490,5 +2490,5 @@
     if (g_cProcessorGroups > 1)
     {
-        GROUP_AFFINITY Affinity = { 0 /* == all active apparently */ , pWorker->iProcessorGroup, { 0, 0, 0 } };
+        GROUP_AFFINITY Affinity = { 0 /* == all active apparently */, pWorker->iProcessorGroup, { 0, 0, 0 } };
         BOOL fRet = g_pfnSetThreadGroupAffinity(GetCurrentThread(), &Affinity, NULL);
         assert(fRet); (void)fRet;
