make install: rename, never copy over a mapped file
cp truncates the inode a running splinter has mapped, so the pages under a live gateway change and it jumps into garbage. That is what killed the daemon while make install ran (SIGSEGV at 0xb176). Link to a temp name and rename; the old inode stays mapped for whatever is already running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fdf8b2888d
commit
be2ab165f7
1 file changed
+15
-3
@@ -270,14 +270,26 @@ check: $(LIB) $(BIN) $(PLUGIN) $(TESTS)
|
||||
# The installed binary finds its own library through an rpath relative to itself
|
||||
# ($ORIGIN), so 'make install PREFIX=$HOME/.local' produces a program that runs
|
||||
# without a wrapper, without LD_LIBRARY_PATH and without an environment file.
|
||||
# Install by rename, never in place. A running splinter has these files
|
||||
# mapped: cp truncates the old inode and writes into pages the process is
|
||||
# executing, which killed a gateway that was up while make install ran
|
||||
# (SIGSEGV at a nonsense address). A rename swaps the directory entry and
|
||||
# leaves the mapped inode alone.
|
||||
install: all
|
||||
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib \
|
||||
$(DESTDIR)$(PREFIX)/lib/splinter/plugins
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../lib' \
|
||||
-o $(DESTDIR)$(PREFIX)/bin/splinter $(BINOBJ) -L. -lsplinter \
|
||||
-o $(DESTDIR)$(PREFIX)/bin/.splinter.new $(BINOBJ) -L. -lsplinter \
|
||||
$(CURSES_A) $(LIBS)
|
||||
cp $(LIB) $(DESTDIR)$(PREFIX)/lib/
|
||||
cp $(PLUGIN) $(DESTDIR)$(PREFIX)/lib/splinter/plugins/
|
||||
mv -f $(DESTDIR)$(PREFIX)/bin/.splinter.new \
|
||||
$(DESTDIR)$(PREFIX)/bin/splinter
|
||||
cp $(LIB) $(DESTDIR)$(PREFIX)/lib/.$(LIB).new
|
||||
mv -f $(DESTDIR)$(PREFIX)/lib/.$(LIB).new $(DESTDIR)$(PREFIX)/lib/$(LIB)
|
||||
for p in $(PLUGIN); do \
|
||||
cp "$$p" "$(DESTDIR)$(PREFIX)/lib/splinter/plugins/.new.$$$$" && \
|
||||
mv -f "$(DESTDIR)$(PREFIX)/lib/splinter/plugins/.new.$$$$" \
|
||||
"$(DESTDIR)$(PREFIX)/lib/splinter/plugins/$${p##*/}" || exit 1; \
|
||||
done
|
||||
@echo "installed $(DESTDIR)$(PREFIX)/bin/splinter"
|
||||
|
||||
clean:
|
||||
|
||||
Reference in new issue
Block a user