- Timestamp:
- Sep 11, 2015 3:51:18 PM (9 years ago)
- Location:
- trunk/src/VBox/Additions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxService.cpp
r57659 r57721 71 71 int g_cVerbosity = 0; 72 72 char g_szLogFile[RTPATH_MAX + 128] = ""; 73 char g_szPidFile[RTPATH_MAX] = ""; 73 74 /** Logging parameters. */ 74 75 /** @todo Make this configurable later. */ … … 290 291 } 291 292 293 /* 294 * Create the PID file. 295 */ 296 int vboxServiceCreatePidFile(const char *pszPidFile) 297 { 298 RTFILE hFile; 299 int rc = RTFileOpen(&hFile, pszPidFile, RTFILE_O_WRITE | RTFILE_O_TRUNCATE); 300 if (RT_SUCCESS(rc)) 301 { 302 char szPid[32]; 303 RTPROCESS Process = RTProcSelf(); 304 size_t cb = RTStrPrintf(szPid, sizeof(szPid), "%RU64\n", (uint64_t)Process); 305 rc = RTFileWrite(hFile, szPid, cb, NULL); 306 int rc2 = RTFileClose(hFile); 307 if (RT_SUCCESS(rc)) 308 rc = rc2; 309 } 310 if (RT_FAILURE(rc)) 311 VBoxServiceError("Failed to create PID file: %Rrc\n", rc); 312 return rc; 313 } 314 292 315 293 316 /** … … 300 323 RTPrintf("Usage:\n" 301 324 " %-12s [-f|--foreground] [-v|--verbose] [-l|--logfile <file>]\n" 302 " [- i|--interval <seconds>]\n"325 " [-p|--pidfile <file>] [-i|--interval <seconds>]\n" 303 326 " [--disable-<service>] [--enable-<service>]\n" 304 327 " [--only-<service>] [-h|-?|--help]\n", g_pszProgName); … … 314 337 " -f | --foreground Don't daemonize the program. For debugging.\n" 315 338 " -l | --logfile <file> Enables logging to a file.\n" 339 " -p | --pidfile <file> Write the process ID to a file.\n" 316 340 " -v | --verbose Increment the verbosity level. For debugging.\n" 317 341 " -V | --version Show version information.\n" … … 908 932 else if (MATCHES("logfile")) 909 933 psz = "l"; 934 else if (MATCHES("pidfile")) 935 psz = "p"; 910 936 else if (MATCHES("daemonized")) 911 937 { … … 1004 1030 } 1005 1031 1032 case 'p': 1033 { 1034 rc = VBoxServiceArgString(argc, argv, psz + 1, &i, 1035 g_szPidFile, sizeof(g_szPidFile)); 1036 if (rc) 1037 return rc; 1038 psz = NULL; 1039 break; 1040 } 1041 1006 1042 default: 1007 1043 { … … 1125 1161 #endif /* RT_OS_WINDOWS */ 1126 1162 rc = VBoxServiceStartServices(); 1163 if (RT_SUCCESS(rc)) 1164 { 1165 if (strlen(g_szPidFile)) 1166 rc = vboxServiceCreatePidFile(g_szPidFile); 1167 } 1127 1168 rcExit = RT_SUCCESS(rc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE; 1128 1169 if (RT_SUCCESS(rc)) -
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r57661 r57721 1977 1977 char szVar[_1K]; 1978 1978 char szValue[_16K]; 1979 intrc2 = RTEnvGetByIndexEx(hEnv, iVar, szVar, sizeof(szVar), szValue, sizeof(szValue));1979 rc2 = RTEnvGetByIndexEx(hEnv, iVar, szVar, sizeof(szVar), szValue, sizeof(szValue)); 1980 1980 if (RT_SUCCESS(rc2)) 1981 1981 VBoxServiceVerbose(4, "\t%s=%s\n", szVar, szValue); -
trunk/src/VBox/Additions/linux/installer/vboxadd-service.sh
r56860 r57721 94 94 if [ "$system" = "debian" ]; then 95 95 daemon() { 96 start-stop-daemon --start --exec $1 -- $2 96 start-stop-daemon --start --exec $1 -- $2 $3 97 97 } 98 98 … … 121 121 fi 122 122 daemon() { 123 start-stop-daemon --start --exec $1 -- $2 123 start-stop-daemon --start --exec $1 -- $2 $3 124 124 } 125 125 … … 147 147 if [ "$system" = "slackware" -o "$system" = "other" ]; then 148 148 daemon() { 149 $1 $2 149 $1 $2 $3 150 150 } 151 151 … … 172 172 . /etc/rc.d/init.d/functions 173 173 daemon() { 174 loadproc $1 $2 174 loadproc $1 $2 $3 175 175 } 176 176 … … 213 213 } 214 214 testbinary 215 daemon $binary > /dev/null215 daemon $binary --pidfile $PIDFILE > /dev/null 216 216 RETVAL=$? 217 test $RETVAL -eq 0 && echo `pidof VBoxService` > $PIDFILE218 217 succ_msg 219 218 fi
Note:
See TracChangeset
for help on using the changeset viewer.