From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5945 Path: news.gmane.org!not-for-mail From: "piranna@gmail.com" Newsgroups: gmane.linux.lib.musl.general Subject: Re: static build and dlopen Date: Wed, 27 Aug 2014 22:19:18 +0200 Message-ID: References: <20140827164309.GO12888@brightrain.aerifal.cx> <53FE27E6.60902@skarnet.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1409170800 20042 80.91.229.3 (27 Aug 2014 20:20:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 27 Aug 2014 20:20:00 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5952-gllmg-musl=m.gmane.org@lists.openwall.com Wed Aug 27 22:19:56 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XMjhB-00070j-2H for gllmg-musl@plane.gmane.org; Wed, 27 Aug 2014 22:19:53 +0200 Original-Received: (qmail 3089 invoked by uid 550); 27 Aug 2014 20:19:50 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 3081 invoked from network); 27 Aug 2014 20:19:50 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=BSEaw65Sjel8FpDqG9JYFTYz0S3Xjj5v5zKtJKtWdGA=; b=sPGwfM6JZQsZEhXbwa2lAPPPGj1zMZE+8H/Nu0KDtHqd2ecWx6uuKTMJ40Tx1zqwBk b9CaXdnClpeVpTQA0uIjiIPJ57UzDHAh7MSG5ccCNOikElellj0z/aMFKTC/dtIgD4/P nAPUUpych51mO9996t9b+zpFhfeBrr3HxGX+N1QWfvpuhxC2n914SrZGNTZouiLkGfFI 4CaZbvkYyZTPrKCGXxG7JOC/Nkqt0QkRWmS4qQYh777XfyE4JjDjjyGra34glxGjvBqz hlqcRfCfNWRucD4Nwv3TgXC0/jOxMX9erprAJth9neyil+orxh/EBgCfKg24z1IyGdmH KSmQ== X-Received: by 10.194.103.200 with SMTP id fy8mr5781535wjb.123.1409170778583; Wed, 27 Aug 2014 13:19:38 -0700 (PDT) In-Reply-To: <53FE27E6.60902@skarnet.org> Xref: news.gmane.org gmane.linux.lib.musl.general:5945 Archived-At: >> Yes, I though about this option before, has a dumb statically linked >> executable to work as PID 1 that just only exec Node.js and wait until >> it finishes, so I can use a standard dynamically linked one and do >> whatever I want > > I don't understand why you can't do whatever you want anyway. > You can run Node.js as PID 1 even if it is dynamically linked - you > just need to have the libc (and ld-musl.so) in the filesystem. It > will work. You can run anything as PID 1 provided all its dependencies > are there at boot time. Traditional inits are usually dynamically > linked - which I think is a very bad idea, but that's another subject. > If Node.js is a special case that cannot be treated that way, then I'm > interested in hearing why. I tried to do it that way, but didn't worked. Seems on Linux when you are using a dynamically linked executable this is not run directly, but instead it is exec internally /lib/ld-linux.so.2, that's a program that load and link your executable and it's dynamic libraries and later exec it, so it takes the PID 1 and when it finish and give control to your dynamically linked executable (Node.js in this case), then since PID 1 has exited, the kernel has a kernel panic. The same happens if using /usr/bin/env as she-bang, since it will get the PID 1 and fail. You can read all that I have learned about this topics on https://github.com/NodeOS/NodeOS-Docker/pull/12. By the way, based on this example (http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library_23.html#= SEC410) I've done a dumb /init program that just exec the dynamically linked Node.js with the real /init in Javascript and it worked. Ugly hack, but at least it does its job :-) --=20 "Si quieres viajar alrededor del mundo y ser invitado a hablar en un monton de sitios diferentes, simplemente escribe un sistema operativo Unix." =E2=80=93 Linus Tordvals, creador del sistema operativo Linux