I'm not familiar with the interaction of unique_ptr<> and exit().
What happens if you try the following:
grpc::Server* server_ptr = builder.BuildAndStart();
int childpid = fork();
if ( childpid )
exit(0);
server = std::unique_ptr<grpc::Server>(server_ptr);
Also, in the problem you stated, it sounded like you were forking and
exiting the child immediately. The code provided exits the parent process
immediately.
On Tue, Mar 7, 2017 at 1:32 PM, AK <[email protected]> wrote:
> No. The child does nothing but exit. Below is an example of what I am
> doing. If I move the server startup line to the end, everything works fine.
>
> server = std::unique_ptr<grpc::Server>(builder.BuildAndStart());
> int childpid = fork();
> if ( childpid )
> exit(0);
>
>
> On Tuesday, March 7, 2017 at 1:03:01 PM UTC-8, Ken Payson wrote:
>>
>> Are you calling any destructors in the forked process before exit?
>> Destroying the server will call shutdown() on the underlying sockets, which
>> will cause problems for the parent process.
>>
>> Ken
>>
>> On Tue, Mar 7, 2017 at 12:19 PM, AK <[email protected]> wrote:
>>
>>> The forked child simply exits leaving the parent as daemon. I am doing
>>> it in C++ on Ubuntu.
>>>
>>> On Tuesday, March 7, 2017 at 12:07:40 PM UTC-8, Nicolas Noble wrote:
>>>>
>>>> Does the forked child do any gRPC call at all ? Also, which language ?
>>>>
>>>> On Tue, Mar 7, 2017 at 9:40 AM, AK <[email protected]> wrote:
>>>>
>>>>>
>>>>> I am trying to make grpc server a daemon by forking a child and making
>>>>> it exit. But after that the client handshake starts to fail.
>>>>>
>>>>> E0307 01:15:58.221786152 27094 handshake.c:128] Security
>>>>> handshake failed:
>>>>> {"created":"@1488878158.221756436","description":"Handshake
>>>>> read failed","file":"src/core/lib/security/transport/handshake.c"
>>>>> ,"file_line":237,"referenced_errors":[{"created":"@
>>>>> 1488878158.221740996","description":"FD shutdown","file":"src/core/lib
>>>>> /iomgr/ev_epoll_linux.c","file_line":948}]}
>>>>>
>>>>> This happens if fork() is called after the call to BuildAndStart(). If
>>>>> the same fork is done before BuildAndStart() everything works fine.
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "grpc.io" group.
>>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>>> an email to [email protected].
>>>>> To post to this group, send email to [email protected].
>>>>> Visit this group at https://groups.google.com/group/grpc-io.
>>>>> To view this discussion on the web visit
>>>>> https://groups.google.com/d/msgid/grpc-io/1d59f06c-bdad-4a00
>>>>> -9f01-1abcd59a7cbc%40googlegroups.com
>>>>> <https://groups.google.com/d/msgid/grpc-io/1d59f06c-bdad-4a00-9f01-1abcd59a7cbc%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "grpc.io" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at https://groups.google.com/group/grpc-io.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/grpc-io/c2f99403-4ac5-43bf-b9cf-cfdc3eb149da%40googlegroups.com
>>> <https://groups.google.com/d/msgid/grpc-io/c2f99403-4ac5-43bf-b9cf-cfdc3eb149da%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
> You received this message because you are subscribed to the Google Groups "
> grpc.io" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/grpc-io.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/grpc-io/d951fc71-6415-465a-9f56-bf4112c926e1%40googlegroups.com
> <https://groups.google.com/d/msgid/grpc-io/d951fc71-6415-465a-9f56-bf4112c926e1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/grpc-io.
To view this discussion on the web visit
https://groups.google.com/d/msgid/grpc-io/CAGm2-Y5tkfxsJBcwnV4ztivNpHx7u82yXL%2Bzknsf%3D%2BgDmyhwTw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.