File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -87,14 +87,16 @@ long long current_time_m()
8787 return t ;
8888}
8989
90- int save_pid (char * path ) {
90+ int save_pid (const char * path ) {
9191 pid_t pid = getppid ();
9292 FILE * fp = fopen (path , "w+" );
9393 if (!fp ) {
9494 printf ("open file fail\n" );
9595 return 0 ;
9696 }
97- fwrite (& pid , sizeof (pid ), 1 , fp );
97+ char str [10 ];
98+ sprintf (str , "%d" , pid );
99+ fwrite (str , strlen (str ), 1 , fp );
98100 fclose (fp );
99101 fp = NULL ;
100102
Original file line number Diff line number Diff line change 1212extern "C" {
1313#endif /* __cplusplus */
1414
15-
15+ #include <stdio.h>
1616#include <time.h>
1717#include <sys/time.h>
1818#include <sys/types.h>
@@ -94,7 +94,7 @@ long long current_time_m();
9494/**
9595 * 保存进程id
9696 */
97- int save_pid (char * path );
97+ int save_pid (const char * path );
9898
9999#ifdef __cplusplus
100100}
Original file line number Diff line number Diff line change 1313#include " Poco/Base64Decoder.h"
1414#include " Poco/Exception.h"
1515
16+ #include " base/utils.h"
1617#include " h264/NetH264Reader.h"
1718#include " rtmp/RTMPOutPutStream.h"
1819#include " encoder/FLVEncoder.h"
@@ -58,6 +59,9 @@ int main(int argc, char **argv) {
5859 std::stringstream instr;
5960 instr << argv[2 ];
6061 instr << randomstr ();
62+ string pid_path (argv[0 ]);
63+ pid_path = pid_path + " .pid" ;
64+ save_pid (pid_path.c_str ());
6165 if (write_url (instr.str ().c_str ())) {
6266 RTMPOutPutStream output (instr.str ().c_str (), true );
6367 FLVEncoder encoder (&reader, &output);
You can’t perform that action at this time.
0 commit comments