1 /* 2 * (c) 2013 Carsten Weinhold <weinhold@os.inf.tu-dresden.de> 3 * economic rights: Technische Universität Dresden (Germany) 4 * This file is part of TUD:OS and distributed under the terms of the 5 * GNU Lesser General Public License 2.1. 6 * Please see the COPYING-LGPL-2.1 file for details. 7 */ 8 9 #include <stdlib.h> 10 #include <cstdio> 11 #include <unistd.h> 12 13 static void set_initial_cwd(void) __attribute__((constructor)); set_initial_cwd()14static void set_initial_cwd() 15 { 16 char *initial_dir = getenv("INIT_CWD"); 17 if (initial_dir) 18 { 19 int err = chdir(initial_dir); 20 if (err != 0) 21 printf("libinitcwd: could not chdir to '%s'.\n", initial_dir); 22 } 23 } 24 25