Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

229
Visualizações
Process exit code is zero when server running

I have a test suite, with a Main function that returns 1. However, the exit code after the application terminates is 0.

This seems to be related to a ASP.NET server I'm running in the background. If I disable the server, the exit code is 1 as expected.

This code works as expected, and the console reports an exit code of 1 (this is F# syntax, but I'm pretty sure that's not related):

[<EntryPoint>
let main (arts : string array) : int =
  1

while this has an exit code of 0, which is not what I expect:

[<EntryPoint>
let main (arts : string array) : int =
  MyHttpServer.init()
  1

Here's the MyHttpServer.init function:

let init() : Task =
  Host
     .CreateDefaultBuilder()
     .Build()
     .RunAsync()

My question: what is it about having a server running in the background that is causing the exit code to be zero? Is there something in .NET where the exit code is affected by background tasks and threads?

Note: .NET 6 preview 5, but this has happened on all versions I've used from .NET 5 onwards.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Not super familiar with F# syntax, BUT I suspect that if Init() exits b/c of an error/exception, then execution would never reach the line returning a 1, and would therefore exit with a value of 0.

EDIT: If an exception is thrown when calling Init, or if an exception is thrown before Init can return, the unhandled exception would terminate the process, and the code that returns 1 would not be executed.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda