Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't remove socket when exiting forked process #130

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions sam/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,13 @@ connectto(char *machine)
close(p2[0]);
}

bool forked;

void
removesocket(void)
{
if (forked)
return;
close(exfd);
unlink(exname);
exname[0] = 0;
Expand Down Expand Up @@ -348,6 +352,7 @@ startup(char *machine, bool rflag, bool trylock)
if (!rflag)
bootterm(machine);

forked = false;
downloaded = true;
outTs(Hversion, VERSION);
}
2 changes: 1 addition & 1 deletion sam/sam.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bmain(int argc, char *argv[])
void
rmsocket(void)
{
if (rmsocketname)
if (rmsocketname && !forked)
unlink(rmsocketname);
}

Expand Down
1 change: 1 addition & 0 deletions sam/sam.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ extern String plan9cmd;
extern bool downloaded;
extern bool eof;
extern bool bpipeok;
extern bool forked;
extern bool panicking;
extern wchar_t empty[];
extern int termlocked;
Expand Down
2 changes: 2 additions & 0 deletions sam/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <limits.h>

extern jmp_buf mainloop;
extern bool forked;

char errfile[PATH_MAX + 1];
String plan9cmd; /* null terminated */
Expand Down Expand Up @@ -35,6 +36,7 @@ plan9(File *f, int type, String *s, int nest)
if(downloaded)
remove(errfile);
if((pid=fork()) == 0){
forked = true;
if(downloaded){ /* also put nasty fd's into errfile */
fd = creat(errfile, 0600L);
if(fd < 0)
Expand Down