VirtualBox

Changeset 4555 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 6, 2007 12:24:20 AM (17 years ago)
Author:
vboxsync
Message:

the psinfo format is psinfo_t.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/VBox/log-vbox.cpp

    r4071 r4555  
    122122# if defined(RT_OS_WINDOWS)
    123123#  include <Windows.h>
    124 # elif defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
     124# elif defined(RT_OS_LINUX)
     125#  include <unistd.h>
     126# elif defined(RT_OS_SOLARIS)
     127#  define _STRUCTURED_PROC 1
     128#  include <sys/procfs.h>
    125129#  include <unistd.h>
    126130# elif defined(RT_OS_L4)
     
    296300        RTLogLoggerEx(pLogger, 0, ~0U, "Commandline: %ls\n", GetCommandLineW());
    297301
    298 # elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) || defined(RT_OS_SOLARIS)
     302# elif defined(RT_OS_SOLARIS)
     303        psinfo_t psi;
     304        char szArgFileBuf[80];
     305        RTStrPrintf(szArgFileBuf, sizeof(szArgFileBuf), "/proc/%ld/psinfo", (long)getpid());
     306        FILE* pFile = fopen(szArgFileBuf, "rb");
     307        if (pFile)
     308        {
     309            if (fread(&psi, sizeof(psi), 1, pFile) == 1)
     310            {
     311#  if 0     /* 100% safe:*/
     312                RTLogLoggerEx(pLogger, 0, ~0U, "Args: %s\n", psi.pr_psargs);
     313#  else     /* probably safe: */
     314                const char * const *argv = (const char * const *)psi.pr_argv;
     315                for (int iArg = 0; iArg < psi.pr_argc; iArg++)
     316                    RTLogLoggerEx(pLogger, 0, ~0U, "Arg[%d]: %s\n", iArg, argv[iArg]);
     317#  endif
     318
     319            }
     320            fclose(pFile);
     321        }
     322
     323# elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
    299324#  ifdef RT_OS_LINUX
    300325        FILE *pFile = fopen("/proc/self/cmdline", "r");
    301 #  elif defined(RT_OS_SOLARIS)
    302         /*
    303          * I have a sinking feeling solaris' psinfo format could be different from cmdline
    304          * Must check at run time and possible just ignore this section for solaris
    305          */
    306         char szArgFileBuf[80];
    307         RTStrPrintf(szArgFileBuf, sizeof(szArgFileBuf), "/proc/%ld/psinfo", (long)getpid());
    308         FILE* pFile = fopen(szArgFileBuf, "r");
    309326#  else /* RT_OS_FREEBSD: */
    310327        FILE *pFile = fopen("/proc/curproc/cmdline", "r");
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette