Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 07d4d36

Browse files
committed
On solaris, createdb/dropdb fails because of strange behavior of system().
(it returns error with errno ECHILD upon successful completion of commands). This fix ignores an error from system() if errno == ECHILD.
1 parent c439756 commit 07d4d36

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/backend/commands/dbcommands.c

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.53 2000/04/12 17:14:58 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.54 2000/05/25 06:53:43 ishii Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -148,13 +148,21 @@ createdb(const char *dbname, const char *dbpath, int encoding)
148148

149149
snprintf(buf, sizeof(buf), "cp %s%cbase%ctemplate1%c* '%s'",
150150
DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR, loc);
151+
#if defined(sun)
152+
if (system(buf) != 0 && errno != ECHILD)
153+
#else
151154
if (system(buf) != 0)
155+
#endif
152156
{
153157
int ret;
154158

155159
snprintf(buf, sizeof(buf), "rm -rf '%s'", loc);
156160
ret = system(buf);
161+
#if defined(sun)
162+
if (ret == 0 || errno == ECHILD)
163+
#else
157164
if (ret == 0)
165+
#endif
158166
elog(ERROR, "CREATE DATABASE: could not initialize database directory");
159167
else
160168
elog(ERROR, "CREATE DATABASE: Could not initialize database directory. Delete failed as well");
@@ -281,7 +289,11 @@ dropdb(const char *dbname)
281289
* Remove the database's subdirectory and everything in it.
282290
*/
283291
snprintf(buf, sizeof(buf), "rm -rf '%s'", path);
292+
#if defined(sun)
293+
if (system(buf) != 0 && errno != ECHILD)
294+
#else
284295
if (system(buf) != 0)
296+
#endif
285297
elog(NOTICE, "DROP DATABASE: The database directory '%s' could not be removed", path);
286298
}
287299

0 commit comments

Comments
 (0)